This is a template for a Node.js project that uses Yarn as the package manager, Express as the web framework, Mongoose as the database ORM, Bcrypt for password hashing, JWT token for authentication, Prettier for code formatting, ESLint for code quality, and Husky for git hooks.
To install the dependencies, run the following command:
yarn
To configure the project, create a .env
file at the root of the project and set the following environment variables:
PORT=3000
AUTH_SECRET=your_jwt_secret
DB_HOST=your_db_host
DB_PORT=your_db_port
DB_NAME=your_db_name
SALT_WORK_FACTOR=number_of_rounds
To start the server, run the following command:
yarn dev
The project uses ESLint for code quality checks. To run the checks, run the following command:
yarn lint
yarn lint:fix
The project uses Husky for git hooks. The pre-commit hook runs Prettier and ESLint on staged files. Also, I have set up auto save in VSCode user settings, which helps you to automatically format and lint code on save.