Docs / Programming & Development / How to Set Up a NestJS API Server

How to Set Up a NestJS API Server

By Admin · Mar 1, 2026 · Updated Apr 23, 2026 · 23 views · 1 min read

What Is NestJS?

NestJS is a progressive Node.js framework for building efficient, scalable server-side applications. It uses TypeScript by default and follows a modular architecture inspired by Angular. Deploying NestJS on your Breeze provides a robust foundation for enterprise-grade APIs.

Prerequisites

  • A Breeze running Ubuntu 22.04 or later
  • Node.js 18+ installed
  • Nginx installed

Step 1: Install and Create a Project

sudo npm install -g @nestjs/cli
nest new my-api
cd my-api

Step 2: Build for Production

npm run build

This compiles TypeScript to JavaScript in the dist/ folder.

Step 3: Create a Systemd Service

sudo nano /etc/systemd/system/nestjs.service
[Unit]
Description=NestJS API
After=network.target

[Service]
User=www-data
WorkingDirectory=/var/www/my-api
ExecStart=/usr/bin/node dist/main.js
Restart=always
Environment=NODE_ENV=production
Environment=PORT=3000

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now nestjs

Step 4: Nginx Reverse Proxy

server {
    listen 80;
    server_name api.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
sudo ln -s /etc/nginx/sites-available/nestjs /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d api.yourdomain.com

Adding Modules

Generate resources quickly: nest g resource users creates a controller, service, module, and DTOs. NestJS supports TypeORM, Prisma, and Mongoose for database integration.

Was this article helpful?