Skip to content

Snapshot for @system-core/core 0.8.x. Current docs live at /.

NestJS API On System-Core

Recipe

Use this when NestJS owns the HTTP API shell but system-core still owns the package runtime.

Target Outcome

  • NestJS provides modules, controllers, guards, and dependency injection.
  • system-core owns auth, CMS, delivery, storage, and platform primitives.
  • The NestJS integration package bridges requests into package-owned runtime behavior.

Build Shape

  1. Bootstrap createSystem() once during Nest application startup.
  2. Register the resulting runtime in a Nest provider.
  3. Use @system-core/core/integrations/nestjs for adapter-facing glue.
  4. Build controllers and services on system.auth, system.cms, and system.delivery.

Install

bash
npm install @system-core/core zod @prisma/client
npm install bcryptjs jsonwebtoken nodemailer

Add Nest and host-framework packages in the application itself, then add these only when needed:

  • Redis-backed limits or queues: npm install ioredis
  • S3 media storage: npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner

Bootstrap Provider

ts
import { createSystem } from '@system-core/core'

export const systemProvider = {
  provide: 'SYSTEM_CORE',
  useFactory: async () => {
    return createSystem({ prisma, media })
  }
}

Service Usage

ts
import { Inject, Injectable } from '@nestjs/common'

@Injectable()
export class PagesService {
  constructor(@Inject('SYSTEM_CORE') private readonly system: Awaited<ReturnType<typeof createSystem>>) {}

  listPublished() {
    return this.system.cms.listPublishedPages()
  }
}

Guardrails

  • Keep NestJS as the host shell, not the owner of auth or CMS logic.
  • Centralize the runtime instance; do not create a new system per request.
  • Prefer package-owned permission and session flows over duplicate Nest services.

Follow With

system-core documentation for maintainers, integrators, and AI build agents.