- Node.js
- Express.js
- MongoDB
- Jest
To run this application locally, follow the steps below:
-
Clone the repository:
git clone https://github.com/Akashdeep-k/nodejs-api cd nodejs-api -
Install the dependencies:
npm install
-
Insert the environment variables in
config/dev.example.envfile and rename it toconfig/dev.env:MONGODB_URI=<your-mongodb-uri> ACCESS_TOKEN_SECRET=<your-access-token-secret> REFRESH_TOKEN_SECRET=<your-refresh-token-secret>
Also, insert the environment variables in
config/test.example.envfile and rename it toconfig/test.env:MONGODB_URI=<your-mongodb-uri> ACCESS_TOKEN_SECRET=<your-access-token-secret> REFRESH_TOKEN_SECRET=<your-refresh-token-secret>
Replace
<your-mongodb-uri>with your MongoDB URI. -
Run the application:
npm start
or
npm run testto run test cases.
-
The application will start on port 3000.
To run this application using Docker, follow the steps below:
-
Repeat the first three steps of the local setup.
-
Build the Docker image:
docker build -t nodejs-api . -
Run the Docker container:
docker run -d -p 3000:3000 nodejs-api
-
The application will start on port 3000.
- GET
/api/v1/users/:userId- Get user by ID - GET
/api/v1/users- Get all users - POST
/api/v1/users- Create a new user - PUT
/api/v1/users/me- Update user - DELETE
/api/v1/users/me- Delete user