Express with TypeScript project structure

Express with TypeScript project structure

Explorer

  • node_modules…, not committed
  • dist…new, not committed
  • coverage…new, not committed
  • src
  • server.ts
  • app.ts
  • worker.tsnew
  • routes.tsnew
  • testsnew
  • setup.tsnew
  • drizzlenew
  • 0000_create_orders.sqlnew
  • meta…new
  • scriptsnew
  • generate-openapi.tsnew
  • openapi.jsonnew
  • .huskynew
  • pre-commitnew
  • commit-msgnew
  • .vscodenew
  • settings.jsonnew
  • extensions.jsonnew
  • launch.jsonnew
  • .devcontainernew
  • devcontainer.jsonnew
  • .envnew, not committed
  • .env.examplenew
  • .gitignore
  • .editorconfig
  • .nvmrc
  • compose.yamlnew
  • drizzle.config.tsnew
  • vitest.config.tsnew
  • eslint.config.jsnew
  • .prettierrc.jsonnew
  • commitlint.config.jsnew
  • package.json
  • package-lock.json
  • tsconfig.json
  • AGENTS.mdnew
  • CLAUDE.mdnew
  • README.md
  1. # Create the folder and package.json

    mkdir orders-api && cd orders-api && npm init -y
  2. # Install Express and its types

    npm install express && npm install -D typescript @types/express @types/node
  3. # Generate a strict tsconfig.json

    npx tsc --init
  4. # Add validation and tests (Growing stage)

    npm install zod && npm install -D vitest supertest @types/supertest
  5. # Add the data layer, logging, auth and jobs (Growing stage)

    npm install drizzle-orm pg pino pino-http jose argon2 bullmq ioredis @asteasolutions/zod-to-openapi && npm install -D drizzle-kit @types/pg
  6. # Add lint, format and hooks (Growing stage)

    npm install -D eslint typescript-eslint prettier husky lint-staged && npx husky init
  7. # Add security and observability (Production stage)

    npm install helmet cors express-rate-limit @sentry/node @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node @opentelemetry/exporter-trace-otlp-http && npm install -D @testcontainers/postgresql