Skip to main content

Quickstart Guide

Get POS Nest API up and running in just a few minutes. This guide will walk you through cloning the repository, setting up your environment, and making your first API call.
Before starting, ensure you have Node.js 18+ and PostgreSQL installed, or a Supabase account for hosted PostgreSQL.

Getting Started

1

Clone the Repository

Clone the POS Nest API repository to your local machine:
git clone <repository-url>
cd pos-nest
2

Install Dependencies

Install all required npm packages:
npm install
This will install all dependencies including:
  • NestJS core packages (v11.0.1)
  • TypeORM (v0.3.28)
  • Supabase JS client (v2.97.0)
  • PostgreSQL driver
  • Validation libraries
3

Configure Environment Variables

Create a .env file in the root directory with your configuration:
.env
# Server Configuration
PORT=3000

# Database Configuration (PostgreSQL)
DATABASE_HOST=your-database-host
DATABASE_PORT=5432
DATABASE_USER=your-database-user
DATABASE_PASS=your-database-password
DATABASE_NAME=pos_nest_db

# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
SUPABASE_BUCKET=products
Never commit your .env file to version control. Keep your SUPABASE_SERVICE_ROLE_KEY secure as it provides admin access to your Supabase project.
4

Start the Development Server

Run the API in development mode with hot reload:
npm run start:dev
You should see output indicating the server is running:
[Nest] 12345  - 03/04/2026, 10:00:00 AM     LOG [NestFactory] Starting Nest application...
[Nest] 12345  - 03/04/2026, 10:00:00 AM     LOG [InstanceLoader] AppModule dependencies initialized
[Nest] 12345  - 03/04/2026, 10:00:00 AM     LOG [NestApplication] Nest application successfully started
The API is now running at http://localhost:3000
5

Create Your First User

Make a signup request to create your first user account:
cURL
curl -X POST http://localhost:3000/auth/signup \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "secure_password123"
  }'
const response = await fetch('http://localhost:3000/auth/signup', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    email: '[email protected]',
    password: 'secure_password123'
  })
});

const data = await response.json();
console.log(data);
Expected Response:
{
  "user": {
    "id": "uuid-here",
    "email": "[email protected]",
    "created_at": "2026-03-04T10:00:00.000Z"
  },
  "session": {
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh_token": "...",
    "expires_in": 3600
  }
}
The password must be at least 6 characters long due to validation rules in src/auth/dto/sign-up.dto.ts
6

Sign In and Get Access Token

Sign in with your credentials to get an access token:
cURL
curl -X POST http://localhost:3000/auth/signin \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "secure_password123"
  }'
Expected Response:
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "...",
  "expires_in": 3600,
  "user": {
    "id": "uuid-here",
    "email": "[email protected]"
  }
}
Save the access_token - you’ll need it for authenticated requests.
7

Make an Authenticated Request

Use your access token to make authenticated API calls. For example, fetch categories:
cURL
curl -X GET http://localhost:3000/categories \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
JavaScript
const response = await fetch('http://localhost:3000/categories', {
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  }
});

const categories = await response.json();
console.log(categories);

What’s Next?

Congratulations! You now have POS Nest API running locally. Here are some next steps:

API Reference

Explore all available endpoints

Authentication

Learn about authentication and authorization

Products

Manage products and inventory

Transactions

Process sales transactions

Common Issues

If port 3000 is already in use, you can change it in your .env file:
PORT=3001
Or set it when starting the server:
PORT=3001 npm run start:dev
Verify your database credentials in the .env file match your PostgreSQL or Supabase configuration. The connection settings are loaded in src/config/typeorm.config.ts:9-13.If using Supabase, ensure:
  • Your project is active
  • Database password is correct
  • Host includes the correct region
Double-check your Supabase configuration:
  • SUPABASE_URL should be your project URL (e.g., https://xxxxx.supabase.co)
  • SUPABASE_SERVICE_ROLE_KEY is the service role key, not the anon key
  • The service role key can be found in Supabase Dashboard under Settings > API
The signup endpoint validates:
  • Email must be a valid email format
  • Password must be at least 6 characters
These validations are defined in src/auth/dto/sign-up.dto.ts:1-12

Development Tips

Watch Mode: The start:dev command uses NestJS watch mode, which automatically reloads when you make changes to your code.
Debug Mode: For debugging, use npm run start:debug to enable Node.js inspector on port 9229.
CORS: CORS is enabled by default in src/main.ts:9-14 with credentials support. Adjust the configuration if you need to restrict origins.

Build docs developers (and LLMs) love