Skip to content

permisdeconstruire/activities-backend

Repository files navigation

nodejs base template ##

This project should be used as a base to integrate every usefull framework for code quality and security.

We tried to follow https://12factor.net/.

What's inside

Linter

We choose eslint with prettier in fix mode with airbnb famous config.

Configuration is explicitly linked to config/eslintrc.yml

yarn run lint

Test

We choose mocha with chai

test directory contains spec tests.

yarn run test

Code coverage

We choose istanbul with nyc mocha to produce lcov files.

yarn run test-report

CI

Using husky lint and test are run before commit and push to add one level of quality.

Using gitlab-ci we run linter, test and report coverage via sonar-scanner

Config

Configuration is read from environment variable. We use dotenv to facilitate the usage.

You can either run MY_VARIABLE=test node index.js or set MY_VARIABLE=test in config/env file.

Of course this file is ignored by git as it can contain sensitive information. Please be careful to not push any copy of your env file renamed in something else.

Logger

We choose winston as logger output in STDOUT with json format in production mode or simple otherwise.

To use the logger, simply add const logger = require('./app/utils/logger'); you can then log using levels

Runner

We choose pm2 as it cover a huge list of feature for running processes.

yarn run pm2 give access to pm2.

As a shortcut to common actions :

yarn run start to start the app

yarn run dev to start the app with live reload on file modification plus logs viewer.

yarn run logs to attach to logs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published