REST API for user management with in-memory database. Supports full cycle of CRUD operations (Create, Read, Update, Delete) with data validation and error handling.
- Create/Read/Update/Delete users
- UUID validation to ensure uniqueness of users
- Full TypeScript support
- Built-in in-memory database
- Error handling with status code messages
- Test coverage of all major scenarios
- TypeScript
- Node.js
- Jest
- Node.js >= 22
- npm >= 11
- Clone the repository:
git clone https://github.com/sergiozeppo/nodejs-crud-api.git
cd nodejs-crud-api- Go to develop branch:
git checkout develop- Install dependencies:
npm install- Use the next base URL:
http://localhost:5000/api/users/The application provides 3 scripts for its running:
- Dev mode:
npm run start:dev- Production mode:
npm run start:prod- Test running:
npm run testAPI provides the following endpoints:
- Endpoint: GET /api/users/
- Description: Retrieves the list of users.
- Response: JSON object of the users.
- Endpoint: GET /api/users/{ID}
- Description: Retrieves a user by ID.
- ID: UUID of the user.
- Response: JSON object of the user.
- Endpoint: POST /api/users/
- Description: Create a new user and puts him in the database
- Response: JSON object of the new user with a new unique id.
- Request Body:
{
"username": string,
"age": number,
"hobbies": [string]
}- Endpoint: PUT /api/users/{ID}
- Description: Updating existing user by his ID
- ID: UUID of the user.
- Response: JSON object of the user after update.
- Endpoint: DELETE /api/users/{ID}
- Description: Deletes user by his ID.
- ID: UUID of the user.
- Response: No response (HTTP status code
204 No Content).