# NestJS + Postgres API

> A NestJS REST API with a notes resource on Postgres, request validation and a health check.

A NestJS 11 REST API with a notes resource on a managed Postgres database, request validation and a health check that tests the database. Click Deploy and Naijacloud builds it from the public repo, creates the Postgres database and connects it, and gives you a live HTTPS address. No GitHub connection needed.

- Use case: API
- Stack: NestJS, Postgres
- Code: https://github.com/naijacloud/template-nestjs-postgres-api (branch `main`)
- Deploy: https://naijacloud.com/new?template=nestjs-postgres-api&ref=template-nestjs-postgres-api
- Free tier: fits (1 app and 1 database per workspace)
- Last verified on Naijacloud: 9 Oct 2026
- Page: https://naijacloud.com/templates/nestjs-postgres-api

## What's inside

- NestJS 11 with a notes module, list, create, read and delete at /notes
- Postgres through pg; the table is created on first boot, retrying while the database starts
- Request validation, and a /healthz that checks the database

## What you get after deploying

- A live address at https://nestjs-postgres-api.naijacloud.app with HTTPS
- A Postgres database, with DATABASE_URL already set on the service
- Build and runtime logs, metrics and redeploys from the dashboard

## Environment variables

| Name | What it is for | Default |
| --- | --- | --- |
| `DATABASE_URL` | Postgres connection | set by Naijacloud |

## Example request

```bash
curl -s https://nestjs-postgres-api.naijacloud.app/notes | jq
```

```
[
  {
    "id": 2,
    "title": "Deployed on Naijacloud",
    "body": "",
    "createdAt": "2026-10-07T03:23:15.919Z"
  },
  {
    "id": 1,
    "title": "First note",
    "body": "",
    "createdAt": "2026-10-07T03:23:15.896Z"
  }
]
```

## Run it locally

```bash
git clone https://github.com/naijacloud/template-nestjs-postgres-api
cd template-nestjs-postgres-api
cp .env.example .env
npm install
npm run dev
```

Learn how it works: [Connecting to a database](https://naijacloud.com/docs/databases/connecting)

All templates: https://naijacloud.com/templates
