- clone the repo
npm install
- Setup temp environment configs (TEST only)
- RUN in CLI from project root
./setenv.sh
if you have bash compatible cli - OR create
.env
file manually
- RUN in CLI from project root
- Make note of generated files and change to your preferences
- IMPORTANT: when deploying app, don't use the
.env
file, simply set vars in your CI provider or container manager
- IMPORTANT: when deploying app, don't use the
- Run eslint
npm run lint
- Run tests (will load up test data in tables)
npm run test
- Run coverage (will load up test data in tables)
npm run coverage
- see results from
coverage/lcov-report/index.html
- Start up app in developer mode (will watch and recompile for changes)
npm run dev
- Start up app in production mode (will watch and recompile for changes)
npm run build
?npm start
- Open browser tab to Swagger UI Explorer to explore API
- Language: Typescript
- Framework: Express
- Documentation: Swagger UI
- Documentation: OpenAPI
- Documentation: Swagger JsDoc
- Configuration: Config
- Environment Variables: Dotenv
- Logging: Pino
- Security: Helmet
- Testing: Jest
- Testing: Supertest
- Code Formatting: Eslint
- Code Formatting: Prettier
- Commit Format: Commitizen
- Commit Format: Commitlint
- Changelog & Versioning
Used swagger-jsdoc for generating Swagger using JSDoc comments in code.
See health route for a simple usage example.
Deployment specific hierarchical configurations are maintained with config module.
To add a system wide configuration parameter, update ./config/default.yaml
.
To add/update an environment or deployment specific configuration parameter, update for ex: ./production.yaml
IMPORTANT: do NOT put critical parameters like keys/passwords in configuration files, and use .env
file described below.
RUN in CLI from project root ./setenv.sh
if you have bash compatible cli, if not create an .env
file accordingly to the script.
Make note of generated files and change to your preferences
IMPORTANT: when deploying app, don't use the .env
file, simply set vars in your CI provider or container manager
adding a new environment variable:
1- update ./setenv.sh
and add a default value
2- update ./env/validators.ts
to validate the value
import { str } from 'envalid';
export default {
// put env validations here
// Envalid parses NODE_ENV automatically, so no need to put it here
DUMMY: str(),
};
And you can use the env variable as below;
import env from './env';
console.log(env.DUMMY);
Pino is used as a logging library in combination with express pino logger and pino pretty
See logger for a basic pino configuration.
This demo app includes automated tests using supertest and jest to test routes, etc.
See example for a simple test route.
This repo is Commitizen-friendly and using use AngularJS's commit message convention also known as conventional-changelog.
To use Commitizen command line interface:
npm run cm
For validating commit message format for users using git commit
, commitlint is used to check if the commit messages meet the conventional commit format.