Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jennypavlova/user-api
https://github.com/jennypavlova/user-api
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jennypavlova/user-api
- Owner: jennypavlova
- Created: 2019-07-27T15:41:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-31T21:40:42.000Z (over 5 years ago)
- Last Synced: 2024-10-29T23:08:35.846Z (2 months ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# User API Implementation
### Project overview
- #### Local setup
- Prerequisites to start the project locally
- Node.js >= 8.10.0
- MongoDB >= 3.2.21
- NPM >= 3.5.2
- Run the project
- ``npm run dev``
- _Note_: The port could be defined in the environmental variable (_process.env.PORT_)
- #### API Endpoints
- ``GET /api/``
- ``GET /api/users``
- ``POST /api/users``
- ``GET /api/users/:userId``
- ``PUT /api/users/:userId``
- ``DELETE /api/users/:userId``
- #### Testing
##### Unit tests
- To run the unit test run
``npm run test``
##### Postman collection
- inport the files from [test/postman](https://github.com/jennypavlova/user-api/tree/master/tests/postman) folder in postman app and execute them in the current order. After the POST request the user id will be populated in the next test to siplify the testing. (Of course you can set the date manually)
- _Note_ the **{{url}}** and **{{id}}** can be changed in the DEV enironment variable
##### Local testing using curl (with example data)
- GET : get all users ``curl http://localhost:8080/api/users``
- POST : create a new user
``curl -d '{"email":"[email protected]", "givenName": "John", "familyName": "Smith"}' -H "Content-Type: application/json" -X POST http://localhost:8080/api/users ``
- PUT : update existing user ( Copy the id from the response of the POST request and replace with the ``_ID_``) :
``curl -d '{"email":"[email protected]", "givenName": "JohnUPDATE", "familyName": "SmithUPDATE"}' -H "Content-Type: application/json" -X PUT http://localhost:8080/api/users/_ID_``
- DELETE : Delete existing user ( Copy the id from the response of the POST request and replace with the ``_ID_``) :
`` curl -X DELETE http://localhost:8080/api/users/_ID_ ``