Getting Started with the Demo Server

Version: 1.0.0

Welcome to RS Tech Hub!

This guide will help you get up and running with a professionally maintained NestJS server in minutes.

The demo server includes the latest RS Tech Hub Nestjs modules to showcase their functionality in a development environment. The modules can be easily extended to your own NestJs classes or can be run with the default configuration. The goal is that you only need to take the minimum amount of possible manual configuration steps.

The demo server can be run as is in a staging or production environment given a valid RS-Tech-Hub license.

The included testing script will run automated queries against the API and will log the output to the console, as well as into a testing report in scripts/testing/reports.

If you have issues getting the server up and running, please don't hesitate to reach out to insights@rs-tech-hub.com.

What You'll Do

By following this guide, you'll set up a complete NestJS backend application with:

  • User authentication - Secure JWT-based auth with refresh tokens, account activation flow and password reset
  • User management - Complete user CRUD operations, lifecycle management and automatic cleanup operations
  • Profile system - User profiles with simple fields
  • Account management - Account lifecycle management
  • GraphQL API - Modern API with Apollo Server
  • Database - PostgreSQL with Prisma ORM

All maintained by RS Tech Hub, so you never worry about security patches or dependency updates again.


Included RS Tech Hub Modules

The demo backend comes pre-configured with these RS Tech Hub modules:

ModulePurpose
@rs-tech-hub/nestjs-account-starterAccount lifecycle management
@rs-tech-hub/nestjs-auth-coreJWT authentication foundation
@rs-tech-hub/nestjs-auth-starterComplete auth flow (signup, login, refresh, password reset)
@rs-tech-hub/nestjs-userUser management suite
@rs-tech-hub/nestjs-prismaPrisma ORM integration
@rs-tech-hub/nestjs-profileSimple user profiles
@rs-tech-hub/nestjs-common-interceptorsRequest/response interceptors
@rs-tech-hub/nestjs-service-operationService layer patterns
@rs-tech-hub/nestjs-clockTimestamp and scheduling utilities
@rs-tech-hub/nestjs-test-starterTesting utilities

Prerequisites

Before you begin, make sure you have:

  • Docker 4+ - For running PostgreSQL database
  • Node.js v24+ - Required for NestJS and modules
  • Yarn or npm - Package manager
  • Git - For cloning the demo repository

Quick Start (5 Minutes)

Step 1: Clone the Demo Repository

git clone https://github.com/RuffSantiDev/rs-tech-hub-demo-backend.git
cd rs-tech-hub-demo-backend

This demo repo includes a pre-configured NestJS application with all RS Tech Hub modules integrated.

Step 2: Set Up Environment Variables

Database Password

  1. Copy the database password template:
    cp dbpw.dev.secret-template.txt dbpw.dev.secret.txt
    
  2. Edit dbpw.dev.secret.txt and add your database password on the first line (no labels, just the password)
  3. The password is loaded automatically by docker-compose

Application Environment

  1. Copy the environment template:
    cp .env-template.txt .env
    
  2. Edit .env and configure these critical variables:
DATABASE_URL=postgres://admin:YOUR_PASSWORD@localhost:5440/dev
DATABASE_PORT=5440
DATABASE_HOST=localhost
NODE_ENV=development
JWT_SECRET=NEEDS_TO_BE_SET
JWT_REFRESH_SECRET=NEEDS_TO_BE_SET
SERVICE_TOKEN=NEEDS_TO_BE_SET
JWT_EXPIRES_IN=NEEDS_TO_BE_SET
REQUEST_SIGNING_SECRET=NEEDS_TO_BE_SET
CSRF_SECRET=NEEDS_TO_BE_SET
SESSION_SECRET=NEEDS_TO_BE_SET
BASIC_AUTH_USERNAME=NEEDS_TO_BE_SET
BASIC_AUTH_PASSWORD=NEEDS_TO_BE_SET
RS_TECH_HUB_NESTJS_LICENSE_KEY=NEEDS_TO_BE_SET_FOR_STAGING_AND_PROD

Important:

  • Replace YOUR_PASSWORD in DATABASE_URL with the same password you set in dbpw.dev.secret.txt
  • Replace all NEEDS_TO_BE_SET values with secure random strings
  • Use openssl rand -base64 32 to generate secure secrets
  • The RS_TECH_HUB_NESTJS_LICENSE_KEY is only required for staging and production environments

Step 3: Start the Database

yarn docker:build:dev

This creates a Docker container with PostgreSQL database:

  • Container name: rs-tech-hub-nestjs-demo-backend
  • Database service: nestjs-starter-backend-db
  • Port: 5440 (configured to avoid conflicts with other PostgreSQL instances)

Step 4: Install Dependencies

yarn install

This installs all required package dependencies, including:

  • NestJS core packages
  • Prisma ORM
  • GraphQL and Apollo Server
  • Authentication libraries (Passport, JWT)

RS-Tech-Hub modules are located in the rs-tech-hub directory

Step 5: Set Up the Database Schema

The prisma client is already pre-generated in ./generated/.prisma based on the current schema.

Please regenerate it if you have applied changes or run into issues.

Generate Prisma Client

yarn prisma:gen

This generates the Prisma client in ./generated/.prisma/client

Note: The client is automatically copied into the RS Tech Hub Prisma module. Alternatively, you can run yarn prisma:copy:client manually, which copies the generated Prisma client into rs-tech-hub/prisma/src/lib/generated/client

Run Database Migrations

yarn prisma:migrate:dev

This initializes the database schema with all required tables:

  • RefreshToken - For JWT refresh token rotation
  • ActivationToken - For email verification
  • PasswordResetToken - For password reset tokens
  • User - Core user data
  • Profile - User profile information
  • UserActivity - Activity tracking
  • Account - Account management

Step 6: Start the Server

Development Mode (with hot reload)

yarn start:dev

Note: RS-Tech-Hub modules will automatically be copied into the dist folder during the build process.

Production Mode

yarn build
yarn start

Your server will start on http://localhost:4000


Testing Your Setup

Automated Testing

Run the Test Script

yarn test:api

This runs the complete API test suite.

Test Reports

The test script automatically creates a detailed test report at:

scripts/testing/reports/{currentDate}_testReport.md

Check your current test report to see all test results and how the server responds to queries.


GraphQL Playground

Open your browser and navigate to:

http://localhost:4000/graphql

The GraphQL Playground provides an interactive interface where you can:

  • Browse the complete API schema
  • Run queries and mutations
  • Test authentication flows

Example Queries

Try these queries in the playground:

Sign Up a New User

Note: Add the service token to your request headers:

{
  "Authorization": "Bearer YOUR_SERVICE_TOKEN_HERE"
}
mutation {
  auth_signUp(
    email: "user@example.com"
    password: "SecurePassword123!"
    firstName: "John"
    lastName: "Doe"
  ) {
    token
    activationKey
    refreshToken
    user {
      id
      email
      Status
      Role
      accountId
      createdAt
      updatedAt
    }
  }
}

Activate the User

mutation Auth_activateUser {
  auth_activateUser(
    input: {
      email: "user@example.com"
      activationKey: "activationKey-from-signup"
    }
  )
}

Log In (Requires Authentication via Bearer Token: service token)

mutation {
  auth_login(email: "user@example.com", password: "SecurePassword123!") {
    token
    refreshToken
    user {
      id
      Status
      Role
      email
      issuerId
      accountId
      createdAt
      updatedAt
    }
  }
}

Get Current User (Requires Authentication via Bearer Token: user auth token)

query {
  auth_currentUser {
    id
    email
    firstName
    lastName
    status
    role
  }
}

Note: Add the access token to your request headers:

{
  "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
}

Available GraphQL Operations

You can explore all operations via the GraphQL Playground at http://localhost:4000/graphql or use Postman to make GraphQL requests.

Authentication: Set either the service token or the user authentication token in the Authorization header as a Bearer Token, depending on the API endpoint requirements.

Queries

Requires Authentication via Bearer Token: Service Token

  • license_getLicenses - View license information
  • auth_verifyEmail - Verify email address
  • account_getById - Fetch account by ID
  • account_validateData - Validate account data
  • user_getById - Fetch user by ID
  • user_getByEmail - Fetch user by email
  • profile_get - Get user profile

Requires Authentication via Bearer Token: User Auth Token

  • auth_currentUser - Get authenticated user
  • user_getCurrent - Get current user details

Mutations

Requires Authentication via Bearer Token: Service Token

  • auth_signUp - Register new user

  • auth_login - Authenticate user

  • auth_refreshToken - Refresh access token

  • auth_logout - End session

  • auth_renewActivationToken - Resend activation email

  • auth_activateUser - Activate user account

  • auth_confirmSignupEmail - Confirm email address

  • account_update - Update account details

  • account_remove - Delete account

  • profile_update - Update user profile

  • test_signUpTestUsers - Create test users (dev only)

  • test_removeTestUsers - Remove test users (dev only)

  • license_resetProductionUsageCount - Reset license usage

Requires Authentication via Bearer Token: User Auth Token

  • auth_updatePassword - Change password

Project Structure

rs-tech-hub-demo-backend/
├── src/
│   ├── app/
│   │   ├── app.module.ts        # Root module with all imports
│   │   └── app.service.ts       # Application service
│   └── main.ts                  # Application entry point
├── prisma/
│   ├── starter-schema.prisma    # Database schema
│   └── migrations/              # Database migrations
├── generated/
│   └── .prisma/client/          # Generated Prisma client
├── scripts/
│   ├── copy-prisma-client.js    # Prisma client copy script
│   └── testing/
│       └── reports/             # Test reports directory
├── .env                         # Environment variables
├── dbpw.dev.secret.txt          # Database password (git-ignored)
├── docker-compose.yml           # Database container config
└── package.json                 # Dependencies and scripts

Next Steps

Now that you have the demo running, you can:

  1. Explore the modules - Check the NPM packages at @rs-tech-hub
  2. Customize your schema - Edit prisma/starter-schema.prisma and run migrations
  3. Add business logic - Build your domain logic on top of the infrastructure
  4. Integrate into your app - Use these modules in your own NestJS project
  5. Extend existing classes - Build on top of RS-Tech-Hub service classes by extending them
  6. Get a license - Visit Gumroad to license for production

Troubleshooting

Port Already in Use

If port 4000 is taken, edit src/main.ts:

const port = process.env.PORT ?? 4000; // Change 4000 to your desired port

Docker Database Issues

Restart the Docker container:

docker-compose down
yarn docker:build:dev

Prisma Client Not Found

Make sure to run the postinstall script:

yarn postinstall

Missing Dependencies

Install all required packages manually:

yarn add graphql @apollo/server
yarn add @nestjs/common @nestjs/core reflect-metadata rxjs
yarn add @nestjs/platform-express
yarn add passport @nestjs/passport passport-jwt @nestjs/jwt passport-local bcrypt axios
yarn add @as-integrations/express5

What Makes This Different?

Unlike typical open-source packages or agency-built code:

Professionally maintained - Security patches within 48 hours
Monthly updates - Dependency updates included
Breaking change notices - Highlighted in the release notes of every release ✅ Long-term commitment - No abandonware, guaranteed support
Production-ready - Battle-tested patterns, not experimental code

You build features. We maintain infrastructure.

Ready to stop rebuilding authentication for the 10th time? Grab your license on Gumroad.


Support & Resources