NestJS Integration
Add schema visualization to your NestJS application with a dynamic module.
Installation
npm install @picadeck/core @picadeck/nestjs
# Plus your parser of choice, e.g.:
npm install @picadeck/mongoose-parserAPI
SchemaVisualizerModule.register(options)
Registers the module with an explicit parser function. The parser receives the NestJS ModuleRef so you can resolve dependencies.
Options:
route— The URL path where the visualizer is served.parser—(moduleRef: ModuleRef) => UniversalSchema | Promise<UniversalSchema>theme—"light" | "dark"(optional)title— Page title (optional)
SchemaVisualizerModule.autoDetect(options)
Automatically probes the NestJS DI container for Mongoose Connection, TypeORM DataSource, Sequelize instance, or Prisma schema file and picks the first one found.
Options:
route— The URL path.theme— Optional.title— Optional.prismaSchemaPath— Path to your.prismafile (optional, defaults to./prisma/schema.prisma).
Manual Registration (Mongoose)
app.module.ts
import { Module } from "@nestjs/common";
import { MongooseModule, getConnectionToken } from "@nestjs/mongoose";
import { SchemaVisualizerModule } from "@picadeck/nestjs";
import { parseMongooseConnection } from "@picadeck/mongoose-parser";
import { Connection } from "mongoose";
@Module({
imports: [
MongooseModule.forRoot("mongodb://localhost:27017/myapp"),
SchemaVisualizerModule.register({
route: "/schema",
parser: async (moduleRef) => {
const connection = moduleRef.get<Connection>(getConnectionToken());
return parseMongooseConnection(connection);
},
}),
],
})
export class AppModule {}Manual Registration (TypeORM)
app.module.ts
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { SchemaVisualizerModule } from "@picadeck/nestjs";
import { parseTypeormDataSource } from "@picadeck/typeorm-parser";
import { DataSource } from "typeorm";
@Module({
imports: [
TypeOrmModule.forRoot({ /* ... */ }),
SchemaVisualizerModule.register({
route: "/schema",
parser: async (moduleRef) => {
const dataSource = moduleRef.get(DataSource);
return parseTypeormDataSource(dataSource);
},
theme: "dark",
}),
],
})
export class AppModule {}Auto Detection
If you prefer zero configuration, use autoDetect. It will scan the DI container for any supported ORM and configure the parser automatically.
app.module.ts
import { Module } from "@nestjs/common";
import { SchemaVisualizerModule } from "@picadeck/nestjs";
@Module({
imports: [
// ... your ORM module (Mongoose, TypeORM, etc.)
SchemaVisualizerModule.autoDetect({
route: "/schema",
theme: "dark",
title: "My NestJS App Schema",
}),
],
})
export class AppModule {}Notes
@nestjs/mongoosedecorators compile to standard Mongoose schemas at runtime -- the parser works as-is.@nestjs/typeormis a thin DI wrapper -- entities use the same TypeORM decorators.- Auto-detection checks for Mongoose Connection, TypeORM DataSource, Sequelize instance, and Prisma schema file in that order.