This is a RESTful API for Linkage Back-End database. The database is MongoDB Atlas
, interacted with via Mongoose and Express.js
. It contains data on users, visits and passwords, which are accessible via the endpoints provided and appropriate GET, POST, PATCH and DELETE methods. A complete list of endpoints and methods is accessible in the endpoints.json
file.
Testing was carried out using Jest and Supertest.
API has been hosted with Heroku here.
Please ensure the following are installed:
- node: v17.8.0
- express: 4.17.3,
- mongoose: 6.2.7
- npm: v8.1.2
To run this project you will need to do the following:
- Clone this repository onto your local machine.
git clone https://github.com/imevanc/nc-group-project
- Navigate inside the folder
cd nc-group-project
- Open the directory in your code editor.
code . (for VScode)
- Install all dependencies
npm install
-
Create a .env file in order to successfully connect to the two databases locally. Inside, add
PORT=5000
,MONGO_URI
andMONGO_TEST
- to connect to test and development databases,TOKEN_SECRET
- to encript passwords. -
Finally to run the server locally enter the following command in your terminal:
npm start
This will run the server on port 9090. All endpoints can be found locally on http://localhost:5000
.
To test the API navigate to the project directory and enter the following command:
npm test
GET /api/users
returns a list of all users
GET /api/visits
returns a list of all visits
GET /api/users/:userId
returns a user object from the id requested
PATCH /api/users/:userId
returns a user object with the updated properties
POST /api/auth/signup
returns a new user object
POST /api/auth/login
returns a user object with a unique access token
DELETE /api/users/:userId
deletes selected user from the array of all users
GET /api/users/:userId/visits
returns an array of all visits corresponding to a user
POST /api/visits
returns a new visit object
GET /api/visits/:visitId
returns a visit object from the id requested
DELETE /api/visits/:visitId
deletes selected visit from the array of all visits
GET /api
returns a json object of the path above, with example responses