Dockerising a node js web-app --->
- Installation of Docker CLI and Desktop
- Understanding Images v/s Containers
- Running Ubuntu Image in Container
- Multiple Containers
- Port Mappings
- Environment Variables
- Dockerization of Node.js Application a. Dockerfile b. Caching Layers c. Publishing to Hub
- Docker Compose a. Services b. Port Mapping c. Env Variables
Attaching few snapshots for points 7 & 8
Snapshots for node js app-dockersiation -> 1. locally buiding docker image and locally running
2. Building new dockerimage and pushing it to hub
3. Docker-compose to manage multiple containers as services (point 8)
Hello There, I have tried to complete all mandatory requirements from 1 to 5 along with Bonus points 6 & 7. I have implemented the project with mentioned technical requirements. Important Note -> I am attaching postman collection json file in which I am adding all API's along with multiple testcases of every API -> Baxture_crud_app_postman_collection.json
Technical requirements
- Task is implemented using Javascript.
- Using 18 LTS version of Node.js with express.js framework
- Asynchronous API's
- Uploading my code to GitHub
Implementation details ->
-
Implemented all endpoint api/users: 1.1 CreateUser - POST api/users server status code 201 - newly created record server status code 400 - if request body does not contain required fields
1.2 ListAllUsers - GET api/users is used to get all persons server status code 200 - On successfull response for entire user list (sending empty array on empty user list) server status code 500 - if any internal server error for async request.
1.3 ListUserById - GET api/users/{userId} server status code 200 - On successfull user fetch from database. server status code 400 - if userId is invalid (not uuid) server status code 404 - if record with id === userId does not exist
1.4 UpdateUserById - PUT api/users/{userId} is used to update existing user server status code 200 - On successfull user updation. server status code 400 - if userId is invalid (not uuid) server status code 404 - if record with id === userId does not exist
1.5 deleteUser - DELETE api/users/{userId} is used to delete existing user from database server status code 204 - On successfull user deletion with no content. server status code 400 - if userId is invalid (not uuid) server status code 404 - if record with id === userId does not exist
-
Users are stored as objects that have described properties - completed
-
Requests to non-existing endpoints - completed
-
server side error handling with human friendly message - completed
-
Maintained .env file for PORT number - completed
Bonus Points -> 6. Two modes of running application (development and production): - completed Added cross-env as a dependency: npm i cross-env - To set environment variables in a cross-platform manner. Modified the script in package.json from
"scripts": {
"start": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
to
"scripts": {
"start:dev": "nodemon server.js",
"start:prod": "cross-env NODE_ENV=production node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
Used cross-env NODE_ENV=production to set the NODE_ENV variable to "production" before running the node server.js command.
application in development mode using: - npm run start:dev (changed normal command of npm start to specifying the environment name)
application in production mode using: - npm run start:prod
-
There could be some tests for API (not less than 3 scenarios). Example of test scenario: completed
7.1 Sending empty array if no user in list on listing all users. 7.2 Sending newly created user record on user creation 7.3 Sending created record on ListUserById 7.4 Deleting a created object with confirmation of successful deletion by sending status code - 204 No content 7.5 Handled ListUser with the deleted user ID does not exist
Few Snapshots ->