This is a Github Repo Template to create Node.js/Express.js based Backend REST APIs
- Basic Express.js App (REST API only; no html rendering) with express generator
- Convert Express.js App to Typescript:
yarn tsc --init
- Add Typescript build script:
yarn build
- Add Production start script:
yarn start
- Add local typescript run script:
yarn start:ts
- Add local typescript run script with file watch (nodemon):
yarn start:watch
- Add Typescript build script:
- Add Jest Testing framework:
yarn test
andyarn test:watch
- Add Auto code formatting with Prettier
- Add dotenv to easily configure app environment variables for local development
- Add VS Code debug config (Reference)
- Add API Authentication with Passport
- Add Backing Database
- node ^10.16.0
- This is the Active LTS release. This is the minimum version any current Node.js app should support. Your team/company can choose a higher major version.
- When you are changing the minimum supported Node.js version, please make sure
tsconfig.json:compilerOptions.target
is compatible with your version of Node.js.- You can use node.green to check which version of Ecmascript is compatible with your version of Node.js.
- This will also be a good time to update the version of
typescript
for this app. It can be updated inpackage.json:devDependencies
. - You can use
yarn upgrade typescript --latest
command to update your typeascript dependency to the latest version. - Make sure other dependencies that depend upon
typescript
are updated as well likets-node
,ts-jest
,jest
, etc.
- yarn ^1.13.0
- Specifying a
yarn
minimum version is very arbitrary but it should still be specified. Your team/company can choose a higher minimum supportedyarn
version.
- Specifying a
yarn install
# for prod deployment
yarn build # Probably run this in your build pipeline
yarn start
# OR #
# for local development
yarn start:ts
# OR #
# for local development with file watch (auto-restart)
yarn start:watch
yarn test # (1) requires 90% code coverage to pass
# OR #
yarn test:watch
(1) This command is setup to run code coverage check as part of the test command. It is meant to be used in CI envrionments to make sure minimum code coverage standard is met. Currently, the minimum code coverage threshold is set to 90%. If you need to change that, please update it in
jest.config.js:coverageThreshold
section.