Node.js and typescript project template

Reading Time: < 1 minutes

A project template with the following configuration:

  • typescript
  • tslint
  • ts configuration file
  • jest to run tests
  • jest configuration file
  • jest reporter
  • code coverage report
  • prettier
  • a test example
  • a package.json with some scripts to build, test, lint and serve

Scripts

      
  "scripts": {
    "build-ts": "rm -rf dist/* && tsc",
    "tslint": "tslint --fix -c tslint.json -p tsconfig.json",
    "serve": "node dist/src/index.js",
    "build": "yarn tslint && yarn build-ts",
    "start": "yarn build && yarn serve",
    "start:dev": "nodemon",
    "test": "NODE_ENV=test jest --runInBand --detectOpenHandles --forceExit  --logHeapUsage test/*",
    "prettier": "prettier --check './**/*.ts'",
    "validate": "yarn prettier && yarn tslint && yarn build-ts"
  },
      
    

Dev dependencies

      
  "devDependencies": {
    "@types/jest": "^27.0.2",
    "@types/node": "^ 16.10.3",
    "@types/supertest": "^2.0.10",
    "jest": "^27.2.4",
    "jest-html-reporter": "^3.3.0",
    "nodemon": "^2.0.6",
    "nyc": "^15.1.0",
    "prettier": "^2.1.2",
    "supertest": "^6.0.1",
    "ts-jest": "^27.0.5",
    "ts-node": "^10.2.1",
    "tsc": "^2.0.3",
    "tslint": "^6.1.3",
    "tslint-config-prettier": "^1.18.0",
    "tslint-plugin-prettier": "^2.3.0",
    "typescript": "^4.4.3"
  },
      
    

The code

https://github.com/andrescanavesi/node-js-ts-template


About the author

Andrés Canavesi
Andrés Canavesi

Software Engineer with 15+ experience in software development, specialized in Salesforce, Java and Node.js.


Related posts


Leave a Reply

%d bloggers like this: