From 877a83ac895325e1f4a8d8d5bed0bbe905567528 Mon Sep 17 00:00:00 2001 From: Zain Ali Date: Sun, 29 Mar 2026 18:09:03 +0500 Subject: [PATCH] make readme file --- Dockerfile | 3 ++- README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ app.js | 5 +++- nodemon.json | 2 +- 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2b8e857..04a27f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM node:22-alpine WORKDIR /app COPY package.json package-lock.json ./ -RUN npm install --omit=dev +COPY . . +RUN npm install CMD ["npm","start"] EXPOSE 3000 \ No newline at end of file diff --git a/README.md b/README.md index e69de29..c874455 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,75 @@ +# Template Repository + +- The repository is template setup for nodejs project that have setup of eslint, prettier, eslint+prettier, husky, docker, swagger Api, .gitignore, rules of eslint, separate folder inside src, services and prisma ORM setup. + +## Eslint + prettier + +- Their is eslint + prettier setup of rules which warn unused variable and noUnd. and reformat code when saved the file. + +## husky + +- When we try to commit with errors in project or the hook that return before commit will not do commit before task that are written in husky file. + +## Docker Setup + +- The docker is already setup in project if three or five developers working on same project then they have all to install software, dependency. By using docker you containerize your application and you can easily put on production container. + +## Swagger Api + +- The swagger api provide documentation of https request. + +## src Folder + +- There is different folder for controllers, model, routes and service. + +## Prisma ORM setup + +- Object Relational Model is bridge between database and the javascript language. Model is like language of bridge. Schema is translator language. + `npx prisma init` : For intializing of prisma in project. + + `npx prisma migrate dev` : For generating migration of database + +### 1. Build the image + +```bash +docker build -t nodejs-base-project . +``` + +--- + +### 2. Run the container + +```bash +docker run -p 3000:3000 --name bookstore-backend nodejs-base-project +``` + +--- + +### 3. Verify it’s running + +Open: + +``` +http://localhost:3000/health +``` + +## Cleanup + +Stop container: + +```bash +docker ps +docker stop +``` + +Remove container: + +```bash +docker rm +``` + +Remove image: + +```bash +docker rmi nodejs-base-project +``` diff --git a/app.js b/app.js index fa0970d..0710c23 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,10 @@ import swaggerDocument from './swagger.json' with { type: 'json' }; const PORT = 3000; const app = express(); app.get('/health', (req, res) => { - res.send({ message: 'Healthy gamers' }); + res.send({ message: 'Site is healthy.' }); }); app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); app.listen(PORT); +app.post('/book', (req, res) => { + res.send(); +}); diff --git a/nodemon.json b/nodemon.json index 4b8281e..3cea6a4 100644 --- a/nodemon.json +++ b/nodemon.json @@ -3,5 +3,5 @@ "ext": "json,js,.env,ts", "ignore": ["node_modules/", "*.test.js"], "delay": 1000, - "exec": "node src/server.js" + "exec": "node app.js" }