GithubHelp home page GithubHelp logo

bobby-tav / human-rights-first-docdb-be Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bloomtech-labs/human-rights-first-docdb-be

0.0 0.0 0.0 614 KB

License: MIT License

JavaScript 100.00%

human-rights-first-docdb-be's Introduction

Human Rights First logo

You can learn more about Human Rights First HERE

Tech Stack Used

  • Javascript
  • NodeJS with ExpressJS framework
  • npm
  • PostgreSQL

Environment Variables

  • PORT - API port (optional, but helpful with FE running as well)
    • The following ports are whitelisted for use with Okta
      • 3000
      • 8000
      • 8080
  • DS_API_URL - URL to a data science API
  • DS_API_TOKEN - SECRET authorization header token for data science API
  • DATABASE_URL - connection string for postgres database
  • OKTA_URL_ISSUER - The complete issuer URL for verifying Okta access tokens. https://example.okta.com/oauth2/default
  • OKTA_CLIENT_ID - the Okta client ID.

See .env.sample for example values

Setup the application

  • create your project repo by forking or using this as a template.
  • run: npm install to download all dependencies.
  • run: cp .env.sample .env and update the environment variables to match your local setup.
  • run: npm run migrate to create the starting schema.
  • run: npm run seed to populate your db with some data.
  • run: npm run tests to confirm all is setup and tests pass.
  • run: npm run watch:dev to start nodemon in local dev environment.


Starting here is a placeholder until HRF BE crew says otherwise

API Documentation:

Admins and Users:

[GET] /api/users - returns an array filled with user objects similar to the following:

[
  {
    user_id: 1,
    password: "$2a$08$R//PP9zaFmo5t3RYL4Yh0ONj.68YU2UQ5HlXbt8TbD.WHFMweWCsG",
    name: "Fred",
    email: "[email protected]",
    role: "admin"
  }, {
    user_id: 2,
    password: "$2a$08$6TceWJyijzXrBAQlP.ZsW.o1y1MmmfJaCb3GPlJ.LnC3eYKtiWbzK",
    name: "Shaggy",
    email: "[email protected]",
    role: "user"
  }
]

Authentication:

Method URL Description
[POST] /api/auth/register Requires a username, password, name, and email. Registers a new user.
[POST] /api/auth/login Requires a username and password. Logs the user in.

Users:

Method URL Description
[GET] /api/users/ Returns an array filled with user objects.
[GET] /api/users/:id Returns the user object with the specified user_id.
[DELETE] /api/users/:id Removes the user with the specified user_id and returns the deleted user.
[PUT] /api/users/:id Updates the user with the specified user_id using data from the request body. Returns the modified user

Events:

Method URL Description
[POST] /api/events/ Requires organizer_id, title, date (in the format of mm/dd/yyyy), time (in the format of 03:00), and a location. Returns the event object with the specified event_id.
[GET] /api/events/ Returns an array filled with event objects.
[GET] /api/events/:id Returns the event object with the specified event_id.
[DELETE] /api/events/:id Removes the event with the specified event_id and returns the deleted event.
[PUT] /api/events/:id Updates the event with the specified event_id using data from the request body. Returns the modified event

Guests:

Method URL Description
[GET] /api/events/:id/guests Returns an array filled with guests attending the event.
[POST] /api/events/:id/guests Requires a user_id and a boolean of attending (true or false). Adds a guest to the event.
[DELETE] /api/events/:id/guests Requires user_id Removes the guest with the specified user_id and returns the new list of guests.

Items:

Method URL Description
[GET] /api/events/:id/items Returns an array filled with items for the event.
[POST] /api/events/:id/items Requires an item_name and a name (name of the person bringing the item) and adds the new item to the list of items
[DELETE] /api/events/:id/items Requires item_name Removes the item with the specified item_name and returns the new list of items.

END PLACEHOLDER

Setup postgres

There are 3 options to get postgresql installed locally [Choose one]:

  1. Use docker. Install for your platform
    • run: docker-compose up -d to start up the postgresql database and pgadmin.
    • Open a browser to pgadmin and you should see the Dev server already defined.
    • If you need to start over you will need to delete the folder $ rm -rf ./data/pg as this is where all of the server data is stored.
      • if the database api-dev was not created then start over.
  2. Download and install postgresql directly from the main site
    • make note of the port, username and password you use to setup the database.
    • Connect your client to the server manually using the values previously mentioned
    • You will need to create a database manually using a client.
    • Make sure to update the DATABASE_URL connection string with the values for username/password, databasename and server port (if not 5432).
  3. Setup a free account at ElephantSQL
    • Sign up for a free Tiney Turtle plan
    • copy the URL to the DATABASE_URL .env variable
    • make sure to add ?ssl=true to the end of this url

Contributing

See the contributing doc for more info.

human-rights-first-docdb-be's People

Contributors

christina-yun avatar paulstgermain avatar dominthebox avatar bradfordmez avatar fervelgo avatar crayburn18 avatar collerhatguy avatar tdubs42 avatar julianevo avatar ryan-hamblin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.