Skip to content

NeoCoast/node-boilerplate

Repository files navigation

node-boilerplate

Boilerplate for Node.js applications

Main Characteristics

Other features

dotenv

We use dotenv for environment variables

Passport, jsonwebtoken, bcrypt

Passport is used for authentication, with Local Strategy (for username and password authentication) and JWT Strategy (for token authentication) jsonwebtoken is used for creating session tokens and bcrypt for encrypting user passwords before saving to the DB.

Morgan and Winston

Morgan is used to log incoming requests, combined with Winston for a super logging experience.

Tests

We use mocha, supertest and expect for writing tests. On top of that we use faker for creating realistic-looking data for tests. Tests can be run using the command npm run test. Pre-commit is used to run tests before committing changes. Changes shouldn't be committed unless all tests are passing, but this step can be skipped using the -n flag.

Code Quality

We use ESLint with eslint-config-airbnb-base plugin for linting. You can run the linter with npm run lint. Pre-commit is used to run the linter before committing changes. Changes shouldn't be committed unless approved bt the linter, but this step can be skipped using the -n flag.

Using this boilerplate

Use the command npm run start to run this boilerplate. We use nodemon to detect changes in the source code and update the app on the fly.

We use sequelize-cli to write and run migrations to the database. Run sequelize-cli db:migrate to run initial migrations.

When receiving and responding to a request, the flow should be controller -> service -> model -> service -> controller -> render service. Most requests shouldn't be handled directly by controllers, instead they should be delegated to services where the business logic can be found. You can read more about this here

About

Boilerplate for Node.JS applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published