Prerequisites
Node.js and npm
The POS Nest API requires Node.js and npm to be installed on your system.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:
PostgreSQL
The API uses PostgreSQL as its database.Install PostgreSQL
Download and install PostgreSQL from postgresql.org or use your system’s package manager:
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.Create a Supabase account
Go to supabase.com and sign up for a free account.
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”
Environment Variables
Create a.env file in the root of your project with the following variables:
Environment Variable Reference
| Variable | Description | Required | Example |
|---|---|---|---|
PORT | Port number for the API server | No (defaults to 3000) | 3000 |
DATABASE_HOST | PostgreSQL host address | Yes | localhost |
DATABASE_PORT | PostgreSQL port number | Yes | 5432 |
DATABASE_USER | PostgreSQL username | Yes | postgres |
DATABASE_PASS | PostgreSQL password | Yes | mypassword |
DATABASE_NAME | PostgreSQL database name | Yes | pos_nest_db |
SUPABASE_URL | Your Supabase project URL | Yes | https://xxx.supabase.co |
SUPABASE_SERVICE_ROLE_KEY | Supabase service role key | Yes | eyJhbGciOiJIUzI1NiIsInR5cCI6... |
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:
Production Environment
For production, set environment variables through your hosting platform (Heroku, AWS, etc.) rather than using a.env file:
Installing Dependencies
Once you have Node.js installed and environment variables configured:Install dependencies
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)
Verify Your Setup
Check that everything is configured correctly:Next Steps
Database Setup
Learn how to create and configure your PostgreSQL database
API Reference
Start exploring the API endpoints
