NestJS API Starter in TypeScript

A NestJS 11 API starter in TypeScript 5 for Node.js 22, for developers who want the standard module, controller and service layout ready to run in a container. It includes Jest unit tests, Supertest end-to-end tests, ESLint and Prettier, a PORT setting and clean shutdown on SIGTERM.

by Light CloudREST APIs

Features

  • NestJS 11 on Express through @nestjs/platform-express, with AppModule, AppController and AppService
  • GET / returns a plain-text greeting from AppService, a placeholder to replace with your first resource
  • TypeScript compiled to dist/ by the Nest CLI; npm run start:dev rebuilds and restarts on change
  • Unit tests with Jest and @nestjs/testing, e2e tests that boot AppModule and call it with Supertest
  • ESLint with typescript-eslint and Prettier, run by npm run lint and npm run format
  • app.enableShutdownHooks() runs Nest's shutdown hooks when the container receives SIGTERM
  • Port read once in src/config.ts from PORT, defaulting to 3000

Tech stack

What you need

  • Free plan: it runs as a server app, and the Free plan includes 3 server apps
  • To run it locally: Node.js 22 or newer and npm
  • No API keys: it starts with nothing to configure

About

This is close to what nest new generates, with two changes for container hosting: the port comes from PORT through src/config.ts, and main.ts enables Nest's shutdown hooks so SIGTERM closes the server cleanly. It has one route and no health endpoint, so the first job is usually npx nest generate resource for your own feature, which adds a module, controller, service and DTOs and imports them into AppModule. Note that npm run lint passes --fix and rewrites files. On Light Cloud the deploy runs npm run build and then npm start (node dist/main), and every push to your copy builds and redeploys.

FAQ

How do I add a new resource in NestJS?

Run npx nest generate resource things. The Nest CLI creates the module, controller, service and DTOs under src/things/ and imports the module into AppModule.

Does this NestJS starter include Swagger docs?

No. Install @nestjs/swagger and set up SwaggerModule in src/main.ts to serve a docs page; nothing else needs to change.

How do I enable CORS in NestJS?

CORS is off. Call app.enableCors({ origin: 'https://example.com' }) in src/main.ts before app.listen.

How do I deploy a NestJS app with a PostgreSQL database?

This starter has no database. The nestjs-postgresql-crud-api template adds one, and deploying it on a paid Light Cloud plan creates the database and sets the connection variables for you.

Can I deploy this NestJS app without Light Cloud?

Yes. It has no Light Cloud code: any host with Node.js 22 runs it with npm ci, npm run build and npm start, with PORT set.

Price
Free
Framework
NestJS · JavaScript
Plan
Free
Updated

Related templates

All rest api starters