NodeJs-Best-Practices is a boilerplate for building Node.js applications with basic user CRUD and login/logout functionality. It uses the Express framework and MongoDB for database storage.
- Node.js version v20.10.0
- Git
- MongoDB
- Postman
-
Initialization command:
npx bootstrap-node-app my-app cd my-app
-
Create Environment File: Create a .env file in the root directory of project and set the required environment variables. Refer to the provided .env.local for reference.
-
Start Project:
npm start
-
Import Postman Collection:
- Find the Postman collection in the "postman collection doc" folder.
- Import Postman collection JSON file from postman
To start the server in the local environment
npm run dev
To start the server in the production environment
npm run prod
-
To watch logs in the production environment
pm2 logs
-
To reload all instances of the production environment
npm run prod-reload
-
To stop all instances of the production environment
npm run prod-stop
-
Atomic Commits: Each commit should represent a single logical change. Avoid combining unrelated changes in a single commit.
-
Meaningful Commit Messages: Write clear and concise commit messages that describe the purpose of the change. Follow the imperative mood (e.g., "Add feature" instead of "Added feature").
-
Commit Types: Commit type must be following one:
- feat: A new feature
- fix: A bug fix
- style: Changes that doesn't affect meaning of code(semi-colon, indentation, etc)
- perf: Improve performance
- refactor: Refactor code
- test: Add missing test cases
- docs: Documentation only change
- chore: Change in auxiliary tools like documentation or seed change
-
Reference Issues: If your commit is related to a specific issue or task, reference it in the commit message. For example,
fix: #123
orfeat: #456
. Here #123 or #456 are ticket Id.
-
Use Hyphens for Branch Names: Use hyphens to separate words in branch names. For example, use
feature-branch
instead offeature_branch
orfeatureBranch
. -
Prefix Branch Names: Prefix branch names with a category or type. For example:
-
feature/
for feature branches -
fix/
for fix branches
-