@rs-tech-hub/nestjs-account-starter

Basic account management for NestJS applications with GraphQL support. Create, read, update, and delete user accounts with built-in validation and email uniqueness checks.


📚 Table of Contents


🔑 License

This package requires a valid commercial license. A valid license key must be configured to use this package.

Visit https://rstechhub.gumroad.com to purchase a license.

✨ Features

  • ✅ CRUD operations for account management
  • 🔍 Account retrieval by ID
  • ✉️ Email uniqueness validation
  • 🛡️ Built-in data validation
  • 📊 GraphQL API with resolvers
  • 🔄 Account update with conflict detection

📋 Prerequisites

  • Node.js >= 18
  • TypeScript >= 5.1.0
  • NestJS >= 11.1.6
  • Prisma ORM v7.0+
  • GraphQL support configured in your NestJS application

🚀 Quick Start

Installation

# npm
npm install @rs-tech-hub/nestjs-account-starter \
  @rs-tech-hub/nestjs-license-validator \
  @rs-tech-hub/nestjs-prisma \
  @rs-tech-hub/nestjs-service-operation

# yarn
yarn add @rs-tech-hub/nestjs-account-starter \
  @rs-tech-hub/nestjs-license-validator \
  @rs-tech-hub/nestjs-prisma \
  @rs-tech-hub/nestjs-service-operation

# pnpm
pnpm add @rs-tech-hub/nestjs-account-starter \
  @rs-tech-hub/nestjs-license-validator \
  @rs-tech-hub/nestjs-prisma \
  @rs-tech-hub/nestjs-service-operation

Module Registration

Import the module in your NestJS application:

import { Module } from "@nestjs/common";
import { AccountStarterModule } from "@rs-tech-hub/nestjs-account-starter";

@Module({
  imports: [AccountStarterModule],
})
export class AppModule {}

📖 GraphQL API

Queries

Get Account by ID

query {
  account_getById(accountId: "account-id-here") {
    account {
      id
      name
      primaryEmail
      Type
      createdAt
      updatedAt
    }
  }
}

Validate Account Data

query {
  account_validateData(
    data: {
      name: "Example Company"
      primaryEmail: "contact@example.com"
      Type: BUSINESS
      signupIpAddress: "192.168.1.1"
    }
  ) {
    isValid
    errors
    message
  }
}

Mutations

Create Account

mutation {
  account_create(
    data: {
      name: "Example Company"
      primaryEmail: "contact@example.com"
      Type: BUSINESS
      signupIpAddress: "192.168.1.1"
      isDemoContentReady: false
    }
  ) {
    account {
      id
      name
      primaryEmail
      Type
      createdAt
    }
  }
}

Update Account

mutation {
  account_update(
    id: "account-id-here"
    data: { name: "Updated Company Name", primaryEmail: "newemail@example.com" }
  ) {
    account {
      id
      name
      primaryEmail
      updatedAt
    }
  }
}

Remove Account

mutation {
  account_remove(accountId: "account-id-here") {
    account
  }
}

🔧 Service Usage

Inject the service in your own modules:

import { Injectable } from "@nestjs/common";
import { AccountStarterService } from "@rs-tech-hub/nestjs-account-starter";

@Injectable()
export class YourService {
  constructor(private accountService: AccountStarterService) {}

  async getAccount(id: string) {
    return await this.accountService.getOneById(id);
  }

  async updateAccount(id: string, data) {
    return await this.accountService.handleAccountUpdate(id, data);
  }

  async deleteAccount(id: string) {
    return await this.accountService.removeOneById(id);
  }

  async validateAccount(data) {
    return await this.accountService.validateAccountData(data);
  }
}

📝 Data Types

AccountType Enum

  • PERSONAL - Personal account
  • BUSINESS - Business account

Input Fields

Create Account Input

FieldTypeRequiredDescription
namestringAccount name
primaryEmailstringValid email address
TypeAccountTypeAccount type
signupIpAddressstringIP address at signup
isDemoContentReadybooleanDemo content flag (default: false)

Update Account Input

All fields are optional. Only provided fields will be updated.

⚠️ Error Codes

Error CodeDescription
account-error:validation-failedInput validation failed
account-error:email-already-existsEmail is already in use
account-error:not-foundAccount not found
account-error:creation-failedAccount creation failed
account-error:update-failedAccount update failed
account-error:deletion-failedAccount deletion failed
account-error:id-undefinedAccount ID is undefined

📄 License

This package requires a valid commercial license. See LICENSE.txt for details. By using this software, you agree to the terms outlined in the Software License Agreement (SLA.md). The license grants you specific rights to use, modify, and deploy the software within the scope defined in the agreement. For full terms, conditions, and restrictions, please refer to the Software License Agreement.

📋 Release Notes

1.0.0

  • Initial release

1.0.1

  • Fixes account_getById graphql endpoint
  • Fixes account_validateData graphql endpoint and AccountStarterService.validateAccountData()
  • Removes account_create, accounts should be created through auth_signup
  • Adds ServiceAuthGuards to account_getById, account_validateData,account_update,account_remove
  • Updates internal license handling

📧 Support

For technical support and inquiries: