Implemented a simple CRUD api for work with users using in-memory database underneath.
- TypeScript
- nodemon
- dotenv
- cross-env
- ts-node
- eslint
- uuid
- jest
- supertest
- node.js version: 16 LTS
- Download project files (project located in crud-api branch)
- Go to project root directory
- Run
npm i
npm run start:dev
-> The application is run in development mode using nodemonnpm run start:prod
-> The application is run in production mode (runs the build process and then runs the bundled file)npm run start:multi
-> Runs multiple instances of application using the Node.js Cluster API (equal to the number of logical processor cores on the host machine) with a load balancer that distributes requests across themnpm run lint
-> identify errors found in the code, and generate reports about them.npm run lintfix
-> it detects errors found in the code and tries to fix them.npm run test
-> launches the test runner in the interactive watch mode.
Implemented endpoint api/users
:
- GET
api/users
is used to get all persons- Server should answer with
status code
200 and all users records
- Server should answer with
- GET
api/users/${userId}
- Server should answer with
status code
200 and and record withid === userId
if it exists - Server should answer with
status code
400 and corresponding message ifuserId
is invalid (notuuid
) - Server should answer with
status code
404 and corresponding message if record withid === userId
doesn't exist
- Server should answer with
- POST
api/users
is used to create record about new user and store it in database- Server should answer with
status code
201 and newly created record - Server should answer with
status code
400 and corresponding message if requestbody
does not contain required fields
- Server should answer with
- PUT
api/users/${userId}
is used to update existing user- Server should answer with
status code
200 and updated record - Server should answer with
status code
400 and corresponding message ifuserId
is invalid (notuuid
) - Server should answer with
status code
404 and corresponding message if record withid === userId
doesn't exist
- Server should answer with
- DELETE
api/users/${userId}
is used to delete existing user from database- Server should answer with
status code
204 if the record is found and deleted - Server should answer with
status code
400 and corresponding message ifuserId
is invalid (notuuid
) - Server should answer with
status code
404 and corresponding message if record withid === userId
doesn't exist
- Server should answer with