This is a simple API that allows you to create, read, update and delete users. It is built using Node.js, Express and MongoDB. You can find api documentation at /api-docs
- Clone the repository:
git clone https://github.com/Carbrex/Users-api.git - Install dependencies using pnpm or npm:
pnpm installornpm install - Add environment variable to
.env:
cp example.env .env
- Seed the database:
npm run seed-db
- Start the server:
npm start
- Then, navigate to http://localhost:8080/api-docs to see the API documentation.
- To run tests, use the following command:
npm run test
You need to have docker and docker compose installed on your machine to use this method. Install docker from here.
- Clone the repository:
git clone https://github.com/Carbrex/Users-api.git - Start the docker containers:
docker compose up
- Then, navigate to http://localhost:8080/api-docs to see the API documentation.
- It took me nearly 4 hours and 30 minutes to complete this assignment.
- The most challenging part for me in this project was writing tests for this api. As this was my first time writing tests for a nodejs application, I took help from some github repos and chatgpt to write the tests.
- The link to sample data provided did not work so I used https://jsonplaceholder.typicode.com/users this to get some user data and modified it according to the requirement.
- (Same answer as previoud question)The link to sample data provided did not work so I used https://jsonplaceholder.typicode.com/users this to get some user data and modified it according to the requirement.
- Yes, the assignment was fairly simple but I took time to do each thing perfectly.
- I decided to use Express with Node.js, Swagger and OpenApi for documentation and jests and supertest for tests.
- I assumed that the application didn't need to handle super complex queries or massive amounts of data, so I kept the database schema and queries pretty simple. I also decided to focus more on getting the core functionality right rather than adding a lot of extra features.