-
npm install
-
npm run dev
to start the backend with nodemon (or) -
node server.js
to start the backend without nodemon -
lint:check
to verify style guide -
lint:fix
to fix by style guide recommendations
- Indentation 2 spaces
- Functions, objects and variables use camelCase
- Constants use all caps
- File naming for Models, Controllers and Routes use Test.model.js, Test.controller.js, Test.route.js
-
Separation of concerns. Organizing functions and modules to ensure they have a single, clear task which ensures your code is easy to read and maintain.
-
Modular architecture. Composing your app in pieces that are isolated and easy to understand. This ensures your code is flexible and allows it to be recomposed for cron tasks, unit testing, etc.
-
Web layer. Responsible for sending, receiving, and validating HTTP requests. Common configuration here includes routes, controllers, and middleware.
-
Service layer. Contains business logic.
-
Data access layer. Where we read and write to a database. We typically use an ORM like Mongoose or Sequelize.
This architecture creates a good separation of concerns that will make it easy to read and maintain the code.