An awesome Node.js boilerplate. Come to the node side π
The main goal of Nodevader is to set patterns to be easily implemented on Nodejs projects. We want to make easy to quick start a Nodejs ambient with the basic resources every project could have. Check out the patterns we defined this document bellow.
Icon by Filipe Carvalho
Table of contents
- Requirements
- How to get Started
- Gitflow recommendations
- Patterns and libs
- Samples and tutorials of use
- Project structure
- Licence
This boilerplate supports Node.js from version v12.x
Step by step to get this up and running
git clone https://github.com/stanleygomes/nodevader.git && cd nodevader
npm install
Via express server
npm run dev
Copy enviroment variables template
cp .env.template .env
Via docker-compose (start database, run migrations and start server)
docker-compose up
To test it on the browser, simply go to: http://localhost:3000/welcome
To file a new a feature
- create a branch from
master
branch. Use the pattern:feature/description
- file a pull request on
master
branch - since your PR is aproved, it will be merged to
master
branch - in a moment in time we'll create a release, using the pattern:
release/vX.X.X
These are some of patterns definitions to help us to keep a default arquitecture.
- Package manager: npm, sure
- Node version: v12.x
- Node Framework: Express framework
- Node server: Nodemon and PM2
- Linter: eslint standard pattern
- Database: Use knex query builder and some utils methods on utils/database.js (mysql and postgres support)
- Migrations: Run on a container described in docker-compose file: boxfuse/flyway image
- Template transpiler: Mustache templates
- i18n: take a look here
- Date and time: date-fns
- Test: Mocha & Chai
- Logs: use Winston
- Http Request: use Axios
- Authentication: JWT
- SMTP email: Send emails using Nodemailer and html templates with mustache
- Express: Cors enabled, cookie and body parser, helmet headers
- Migrations: use postgrator, running
npm run migrate
. Place your migrations onsrc/migrations
- Docker compose and dockerfile attached running migrations e starting database and nodejs
Some useful tutorials to improve nodevader's features:
- Main features: check here
- Deploy to firebase functions: check here
Basic folder structure
- src/config: App config (some of these are inherited from .env file), constants, configuration and i18n
- src/api: Endpoints and business logic
- src/static: Images, styles, fonts and other files that can be served
- src/middlewares: Middlewares for routes
- src/routes: Routes, :]
- src/templates: mustache interpreted files
- src/test: Mocha and chai unity tests
- src/utils: Utilities and modules superior layer implementations