Skip to main content
This guide walks you through setting up your local development environment for the POS Nest API project.

Prerequisites

Node.js and npm

The POS Nest API requires Node.js and npm to be installed on your system.
1

Check Node.js version

Verify you have Node.js installed (v18 or higher recommended):
node --version
npm --version
2

Install Node.js (if needed)

If you don’t have Node.js installed, download it from nodejs.org or use a version manager like nvm:
# Using nvm
nvm install 18
nvm use 18

PostgreSQL

The API uses PostgreSQL as its database.
1

Install PostgreSQL

Download and install PostgreSQL from postgresql.org or use your system’s package manager:
# macOS (using Homebrew)
brew install postgresql@15
brew services start postgresql@15

# Ubuntu/Debian
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql

# Windows
# Download installer from postgresql.org
2

Verify PostgreSQL installation

psql --version
Alternatively, you can use a cloud PostgreSQL service like Supabase, AWS RDS, or Heroku Postgres instead of installing locally.

Supabase Account

This API uses Supabase for authentication.
1

Create a Supabase account

Go to supabase.com and sign up for a free account.
2

Create a new project

  • Click “New Project”
  • Choose your organization
  • Enter a project name
  • Set a strong database password
  • Select a region close to you
  • Click “Create new project”
3

Get your credentials

Once your project is created:
  • Go to Project Settings > API
  • Copy your URL and service_role key (you’ll need these for environment variables)
The service_role key bypasses Row Level Security. Keep it secret and never expose it in client-side code or public repositories.

Environment Variables

Create a .env file in the root of your project with the following variables:
# Server Configuration
PORT=3000

# Database Configuration
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USER=postgres
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

Environment Variable Reference

VariableDescriptionRequiredExample
PORTPort number for the API serverNo (defaults to 3000)3000
DATABASE_HOSTPostgreSQL host addressYeslocalhost
DATABASE_PORTPostgreSQL port numberYes5432
DATABASE_USERPostgreSQL usernameYespostgres
DATABASE_PASSPostgreSQL passwordYesmypassword
DATABASE_NAMEPostgreSQL database nameYespos_nest_db
SUPABASE_URLYour Supabase project URLYeshttps://xxx.supabase.co
SUPABASE_SERVICE_ROLE_KEYSupabase service role keyYeseyJhbGciOiJIUzI1NiIsInR5cCI6...
All environment variables are loaded using @nestjs/config which is configured as a global module in the application.

Development vs Production Configuration

Development Environment

For local development, use the .env file with local database credentials:
# Development .env
PORT=3000
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USER=postgres
DATABASE_PASS=postgres
DATABASE_NAME=pos_nest_dev
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your-dev-service-role-key

Production Environment

For production, set environment variables through your hosting platform (Heroku, AWS, etc.) rather than using a .env file:
# Production environment variables
PORT=3000
DATABASE_HOST=your-production-db-host.com
DATABASE_PORT=5432
DATABASE_USER=prod_user
DATABASE_PASS=strong_production_password
DATABASE_NAME=pos_nest_prod
SUPABASE_URL=https://your-prod-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your-prod-service-role-key
  • Never commit .env files to version control
  • Use strong, unique passwords for production databases
  • Consider using managed database services for production
  • The application uses SSL for database connections with rejectUnauthorized: false - consider enabling strict SSL verification in production

Installing Dependencies

Once you have Node.js installed and environment variables configured:
1

Clone the repository

git clone <repository-url>
cd pos-nest
2

Install dependencies

npm install
This will install all dependencies listed in package.json, including:
  • NestJS framework (@nestjs/core, @nestjs/common)
  • TypeORM and PostgreSQL driver (typeorm, pg)
  • Supabase client (@supabase/supabase-js)
  • Validation libraries (class-validator, class-transformer)
3

Verify installation

npm run build
This compiles the TypeScript code and verifies everything is set up correctly.

Verify Your Setup

Check that everything is configured correctly:
# Check Node.js
node --version  # Should be v18+

# Check npm
npm --version

# Check PostgreSQL
psql --version

# Verify .env file exists
ls -la .env

# Install dependencies
npm install

# Build the project
npm run build

Next Steps

Database Setup

Learn how to create and configure your PostgreSQL database

API Reference

Start exploring the API endpoints

Build docs developers (and LLMs) love