Project Setup

A Typed Express Project

Example

mkdir shopease-api && cd shopease-api
npm init -y
npm install express
npm install --save-dev typescript tsx @types/express @types/node
npx tsc --init

Example output

Created a new tsconfig.json
shopease-api/
  src/
    main.ts            create app, listen
    env.ts             validated environment variables
    routes/products.ts
    middleware/auth.ts
    errors.ts
  tsconfig.json
  package.json         "dev": "tsx watch src/main.ts", "build": "tsc", "start": "node dist/main.js"

Note: For larger backends, NestJS gives you structure, dependency injection and decorators on top of Express. See the NestJS material.