This is a RESTful API for managing users. Users can be created, read, updated and deleted using the API.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Node.js (v18.x.x)
- npm (v6.x.x)
- Clone the repository to your local machine:
git clone https://github.com/firtysh/rest-api.git
- Change into the project directory:
cd rest-api
- Install the required dependencies:
npm install
- Create a
.env
file in the root directory of the project with the following contents:
PORT=3000
It can be any port number.
To run the app in development mode, use the following command:
npm run start:dev
The app will be running at http://localhost:3000
.
To run the app in production mode, use the following command:
npm run start:prod
This will build the app and then run the bundled file. The app will be running at http://localhost:3000
.
To run the app in multi-process mode (using the Node.js Cluster
API with a load balancer), use the following command:
npm run start:multi
The load balancer will be running at http://localhost:3000/api
, and the worker processes will be listening on ports 3001
to 3000 + no of CPUs
.
To run the tests, use the following command:
npm test
This will run the tests.
The following endpoints are available:
GET /api/users
- Get all usersGET /api/users/{userId}
- Get a single user by IDPOST /api/users
- Create a new userPUT /api/users/{userId}
- Update an existing userDELETE /api/users/{userId}
- Delete an existing user
- Node.js
- Express
- Javascript
- uuid
- Jest
- Supertest
This project is licensed under the MIT License - see the LICENSE file for details.