Installation Guide
This guide provides detailed instructions for installing and configuring POS Nest API in your development or production environment.Prerequisites
Before installing POS Nest API, ensure you have the following prerequisites:Node.js
Version 18.x or higherDownload from nodejs.org
PostgreSQL
Version 12 or higherOr use Supabase for hosted PostgreSQL
Package Manager
npm, yarn, or pnpmComes with Node.js (npm) or install separately
Supabase Account
Free tier availableSign up at supabase.com
This guide assumes you have basic knowledge of Node.js, TypeScript, and REST APIs.
Installation Steps
1. Clone the Repository
First, clone the POS Nest API repository:2. Install Dependencies
Install all required npm packages using your preferred package manager:- @nestjs/core (v11.0.1) - NestJS framework core
- @nestjs/typeorm (v11.0.0) - TypeORM integration for NestJS
- @supabase/supabase-js (v2.97.0) - Supabase client library
- typeorm (v0.3.28) - ORM for TypeScript and JavaScript
- pg (v8.18.0) - PostgreSQL client for Node.js
- class-validator (v0.14.3) - Validation decorators
- class-transformer (v0.5.1) - Object transformation
- date-fns (v4.1.0) - Date utility library
3. Environment Configuration
Create a.env file in the root directory of the project:
.env file:
.env
Environment Variables Explained
The port number where the API server will listen. Configured in
src/main.ts:21PostgreSQL database host. For Supabase, find this in your project settings under Database > Connection String
PostgreSQL port (default is 5432)
Database username (usually “postgres” for Supabase)
Database password. Set during Supabase project creation
Database name (usually “postgres” for Supabase)
Your Supabase project URL. Found in Supabase Dashboard > Settings > API > Project URL
Supabase service role key for admin operations. Found in Supabase Dashboard > Settings > API > service_role key
Supabase Storage bucket name for product images. Used in
src/upload-image/upload-image.service.ts:144. Supabase Setup
If you’re using Supabase (recommended), follow these steps:Create a Supabase Project
- Go to supabase.com and sign in
- Click “New Project”
- Enter your project details and set a strong database password
- Wait for the project to be provisioned (usually 1-2 minutes)
Get Your Connection Details
In your Supabase Dashboard:
- Go to Settings > Database
- Find the “Connection string” section
- Copy the connection parameters for your
.envfile
- Copy the URL for
SUPABASE_URL - Copy the service_role key for
SUPABASE_SERVICE_ROLE_KEY
Create a Storage Bucket
For product image uploads:
- Go to Storage in the Supabase Dashboard
- Click “New bucket”
- Name it
products(or match yourSUPABASE_BUCKETenv var) - Set it to Public if you want images to be publicly accessible
- Click “Create bucket”
5. Database Setup
The application uses TypeORM with synchronization enabled for development:Database Entities
The following tables will be automatically created when you start the application:- Category - Product categories (
src/categories/entities/category.entity.ts) - Product - Products with inventory (
src/products/entities/product.entity.ts) - Transaction - Sales transactions (
src/transactions/entities/transaction.entity.ts) - Coupon - Discount coupons (
src/coupons/entities/coupon.entity.ts)
Optional: Seed Database
If your project includes a seeder script:6. Running the Application
Development Mode
Run the application in development mode with hot reload:http://localhost:3000 (or your configured PORT).
Production Mode
For production deployment:Debug Mode
To run with debugging enabled:7. Verify Installation
Once the application is running, verify the installation:Application Configuration
CORS Configuration
CORS is configured insrc/main.ts:9-14 with the following settings:
For production, you should restrict the
origin to your specific frontend domain(s) instead of allowing all origins.Global Validation
The application uses global validation pipes configured insrc/main.ts:15-19:
Static Assets
Static files (like uploaded images) are served from thepublic directory:
public directory in the root if it doesn’t exist:
Testing
Run the test suite to ensure everything is set up correctly:Additional Scripts
Other useful commands frompackage.json:
Troubleshooting
SSL/TLS connection errors
SSL/TLS connection errors
If you encounter SSL connection errors with your database, verify that SSL is properly configured in For Supabase, SSL is required and this configuration should work by default.
src/config/typeorm.config.ts:14-16:Module not found errors
Module not found errors
If you get “Cannot find module” errors:
- Delete
node_modulesand lock file: - Reinstall dependencies:
- Clear TypeScript build cache:
TypeORM synchronization issues
TypeORM synchronization issues
If tables aren’t being created automatically:
- Verify
synchronize: trueinsrc/config/typeorm.config.ts:19 - Check database connection credentials
- Ensure your database user has CREATE TABLE permissions
- Check the console for any TypeORM error messages
Supabase authentication not working
Supabase authentication not working
Verify your Supabase configuration:
- Ensure you’re using the service_role key, not the anon key
- Check that your
SUPABASE_URLincludes the full URL withhttps:// - Verify the Supabase project is active in the dashboard
- Check that email authentication is enabled in Supabase Auth settings
Next Steps
Now that you have POS Nest API installed and running:Quickstart
Make your first API calls
Authentication
Learn about auth and authorization
API Reference
Explore all available endpoints
Deployment
Deploy to production
