sternetj / example-express-backend-api

This is a Github Repo Template to create Node.js/Express.js/Typescript based Backend REST APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to example-express-backend-api 👋

This is a Github Repo Template to create Node.js/Express.js based Backend REST APIs

What's included?

  • 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 Jest Testing framework: yarn test and yarn 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

Prerequisites

  • 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 in package.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 like ts-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 supported yarn version.

Install

yarn install

Usage

# 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

Run tests

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.

About

This is a Github Repo Template to create Node.js/Express.js/Typescript based Backend REST APIs


Languages

Language:JavaScript 77.9%Language:TypeScript 22.1%