@nest-arch/tui 0.1.48 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/constants-BbJ71cex.js +1 -0
  3. package/dist/index.js +61 -61
  4. package/dist/templates/base/.gitignore.hbs +3 -0
  5. package/dist/templates/base/README.md.hbs +119 -6
  6. package/dist/templates/base/pnpm-workspace.yaml.hbs +3 -0
  7. package/dist/templates/base/src/app.controller.ts.hbs +10 -0
  8. package/dist/templates/base/src/app.module.ts.hbs +33 -4
  9. package/dist/templates/base/src/app.router.spec.ts.hbs +58 -0
  10. package/dist/templates/base/src/app.router.ts.hbs +26 -0
  11. package/dist/templates/base/src/database/adapters/interfaces/db-adapter.interface.ts.hbs +3 -3
  12. package/dist/templates/base/src/libs/middlewares/auth.trpc.middleware.ts.hbs +42 -0
  13. package/dist/templates/base/src/libs/trpc/context.ts.hbs +13 -0
  14. package/dist/templates/base/src/libs/trpc/error.handler.ts.hbs +10 -0
  15. package/dist/templates/base/src/libs/trpc/inner.context.ts.hbs +7 -0
  16. package/dist/templates/base/src/libs/trpc/protected.ts.hbs +12 -0
  17. package/dist/templates/base/src/libs/trpc/scripts/fix-trpc-generated.mjs.hbs +21 -0
  18. package/dist/templates/base/src/libs/trpc/scripts/watch-trpc.mjs.hbs +91 -0
  19. package/dist/templates/base/src/main.ts.hbs +74 -1
  20. package/dist/templates/extras/swagger/create-docs.ts.hbs +232 -0
  21. package/dist/templates/monorepo/apps/api-gateway/src/app.controller.ts.hbs +10 -0
  22. package/dist/templates/monorepo/apps/api-gateway/src/app.module.ts.hbs +26 -1
  23. package/dist/templates/monorepo/apps/api-gateway/src/main.ts.hbs +73 -0
  24. package/dist/templates/monorepo/root/pnpm-workspace.yaml.hbs +3 -0
  25. package/dist/templates/single-project/architecture/nest-api/pnpm-workspace.yaml.hbs +3 -0
  26. package/dist/templates/single-project/architecture/nest-api/src/main.ts.hbs +73 -0
  27. package/dist/templates/single-project/architecture/nest-gateway/src/main.ts.hbs +73 -0
  28. package/dist/templates/single-project/architecture/nest-microservice/src/main.ts.hbs +74 -0
  29. package/package.json +3 -3
  30. package/dist/constants-D_Ow0fiZ.js +0 -1
@@ -0,0 +1,232 @@
1
+ // @ts-nocheck
2
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, import/no-unresolved */
3
+ /* oxlint-disable import/no-unresolved */
4
+ // oxlint-disable no-unused-vars
5
+
6
+ import type { INestApplication } from "@nestjs/common";
7
+ {{#if hasRest}}
8
+ import {
9
+ DocumentBuilder,
10
+ SwaggerModule,
11
+ type OpenAPIObject,
12
+ } from "@nestjs/swagger";
13
+ {{else}}
14
+ import type { OpenAPIObject } from "@nestjs/swagger";
15
+ {{/if}}
16
+
17
+ interface DocsIntegrations {
18
+ betterAuth?: {
19
+ auth?: unknown;
20
+ pathPrefix?: string;
21
+ prefix?: string;
22
+ };
23
+ trpc?: {
24
+ exportName?: string;
25
+ pathPrefix?: string;
26
+ routerFilePath?: string;
27
+ title?: string;
28
+ version?: string;
29
+ };
30
+ zod?: {
31
+ withFastify?: boolean;
32
+ };
33
+ }
34
+
35
+ export interface CreateDocsOptions {
36
+ title?: string;
37
+ description?: string;
38
+ version?: string;
39
+ extraSpecs?: OpenAPIObject[];
40
+ integrations?: DocsIntegrations;
41
+ }
42
+
43
+ function addPrefixToPaths(paths: Record<string, unknown>, prefix: string) {
44
+ return Object.fromEntries(
45
+ Object.entries(paths).map(([path, value]) => [`${prefix}${path}`, value])
46
+ );
47
+ }
48
+
49
+ function mergeOpenApiSpecs(baseSpec: OpenAPIObject, ...extraSpecs: OpenAPIObject[]) {
50
+ const specs = [baseSpec, ...extraSpecs];
51
+
52
+ return {
53
+ ...baseSpec,
54
+ components: {
55
+ ...baseSpec.components,
56
+ parameters: Object.assign(
57
+ {},
58
+ ...specs.map((spec) => spec.components?.parameters ?? {})
59
+ ),
60
+ responses: Object.assign(
61
+ {},
62
+ ...specs.map((spec) => spec.components?.responses ?? {})
63
+ ),
64
+ schemas: Object.assign(
65
+ {},
66
+ ...specs.map((spec) => spec.components?.schemas ?? {})
67
+ ),
68
+ securitySchemes: Object.assign(
69
+ {},
70
+ ...specs.map((spec) => spec.components?.securitySchemes ?? {})
71
+ ),
72
+ },
73
+ info: baseSpec.info,
74
+ openapi: baseSpec.openapi ?? "3.1.0",
75
+ paths: Object.assign({}, ...specs.map((spec) => spec.paths ?? {})),
76
+ security: specs.find((spec) => spec.security)?.security,
77
+ servers: baseSpec.servers,
78
+ tags: specs.flatMap((spec) => (spec.tags ?? []) as unknown[]),
79
+ } as OpenAPIObject;
80
+ }
81
+
82
+ async function applyZodCleanup(
83
+ baseSpec: OpenAPIObject,
84
+ options?: NonNullable<DocsIntegrations["zod"]>
85
+ ) {
86
+ try {
87
+ const { cleanupOpenApiDoc } = await import("nestjs-zod");
88
+ if (typeof cleanupOpenApiDoc !== "function") {
89
+ return baseSpec;
90
+ }
91
+
92
+ if (options?.withFastify === true) {
93
+ return cleanupOpenApiDoc(baseSpec, { withFastify: true }) as OpenAPIObject;
94
+ }
95
+
96
+ return cleanupOpenApiDoc(baseSpec) as OpenAPIObject;
97
+ } catch {
98
+ return baseSpec;
99
+ }
100
+ }
101
+
102
+ async function applyBetterAuthSpec(
103
+ options?: NonNullable<DocsIntegrations["betterAuth"]>
104
+ ) {
105
+ if (!options?.auth) {
106
+ return null;
107
+ }
108
+
109
+ const authInstance = options.auth as {
110
+ api?: {
111
+ generateOpenAPISchema?: () => OpenAPIObject | Promise<OpenAPIObject>;
112
+ };
113
+ generateOpenAPISchema?: () => OpenAPIObject | Promise<OpenAPIObject>;
114
+ };
115
+
116
+ const schemaGenerator = authInstance.api?.generateOpenAPISchema ?? authInstance.generateOpenAPISchema;
117
+
118
+ if (typeof schemaGenerator !== "function") {
119
+ return null;
120
+ }
121
+
122
+ try {
123
+ const generatedSchema = await schemaGenerator();
124
+ const authSpec = generatedSchema as OpenAPIObject;
125
+ const prefix = options.pathPrefix ?? options.prefix ?? "/auth";
126
+
127
+ if (authSpec.paths) {
128
+ authSpec.paths = addPrefixToPaths(
129
+ authSpec.paths as Record<string, unknown>,
130
+ prefix
131
+ ) as unknown as OpenAPIObject["paths"];
132
+ }
133
+
134
+ return authSpec;
135
+ } catch {
136
+ return null;
137
+ }
138
+ }
139
+
140
+ async function applyTrpcSpec(
141
+ options?: NonNullable<DocsIntegrations["trpc"]>
142
+ ) {
143
+ if (!options?.routerFilePath) {
144
+ return null;
145
+ }
146
+
147
+ try {
148
+ const { generateOpenAPIDocument } = await import("@trpc/openapi");
149
+
150
+ if (typeof generateOpenAPIDocument !== "function") {
151
+ return null;
152
+ }
153
+
154
+ const generatedDocument = await generateOpenAPIDocument(options.routerFilePath, {
155
+ exportName: options.exportName ?? "AppRouter",
156
+ title: options.title ?? "tRPC API",
157
+ version: options.version ?? "1.0.0",
158
+ });
159
+
160
+ const trpcSpec = generatedDocument as OpenAPIObject;
161
+ const prefix = options.pathPrefix ?? "/trpc";
162
+
163
+ if (trpcSpec.paths) {
164
+ trpcSpec.paths = addPrefixToPaths(
165
+ trpcSpec.paths as Record<string, unknown>,
166
+ prefix
167
+ ) as unknown as OpenAPIObject["paths"];
168
+ }
169
+
170
+ return trpcSpec;
171
+ } catch {
172
+ return null;
173
+ }
174
+ }
175
+
176
+ function createEmptyBaseSpec(options: CreateDocsOptions): OpenAPIObject {
177
+ return {
178
+ info: {
179
+ title: options.title ?? "NestJS API",
180
+ description: options.description ?? "Generated with Nest Arch",
181
+ version: options.version ?? "1.0.0",
182
+ },
183
+ openapi: "3.1.0",
184
+ paths: {},
185
+ tags: [],
186
+ } as OpenAPIObject;
187
+ }
188
+
189
+ export async function createDocs(
190
+ app: INestApplication,
191
+ options: CreateDocsOptions = {}
192
+ ): Promise<OpenAPIObject> {
193
+ {{#if hasRest}}
194
+ const config = new DocumentBuilder()
195
+ .setTitle(options.title ?? "NestJS API")
196
+ .setDescription(options.description ?? "Generated with Nest Arch")
197
+ .setVersion(options.version ?? "1.0.0")
198
+ .build();
199
+
200
+ let baseSpec = SwaggerModule.createDocument(app, config) as OpenAPIObject;
201
+ baseSpec = await applyZodCleanup(baseSpec, options.integrations?.zod);
202
+
203
+ if (!baseSpec.paths || Object.keys(baseSpec.paths).length === 0) {
204
+ baseSpec = {
205
+ ...baseSpec,
206
+ info: baseSpec.info ?? {
207
+ title: options.title ?? "NestJS API",
208
+ version: options.version ?? "1.0.0",
209
+ },
210
+ openapi: baseSpec.openapi ?? "3.1.0",
211
+ paths: {},
212
+ tags: [],
213
+ } as OpenAPIObject;
214
+ }
215
+ {{else}}
216
+ const baseSpec = createEmptyBaseSpec(options);
217
+ {{/if}}
218
+
219
+ const additionalSpecs: OpenAPIObject[] = [];
220
+
221
+ const betterAuthSpec = await applyBetterAuthSpec(options.integrations?.betterAuth);
222
+ if (betterAuthSpec) {
223
+ additionalSpecs.push(betterAuthSpec);
224
+ }
225
+
226
+ const trpcSpec = await applyTrpcSpec(options.integrations?.trpc);
227
+ if (trpcSpec) {
228
+ additionalSpecs.push(trpcSpec);
229
+ }
230
+
231
+ return mergeOpenApiSpecs(baseSpec, ...additionalSpecs);
232
+ }
@@ -1,11 +1,21 @@
1
1
  import { Controller, Get } from "@nestjs/common";
2
+ {{#if swagger}}
3
+ import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
4
+ {{/if}}
2
5
 
3
6
  import { AppService } from "./app.service.js";
4
7
 
8
+ {{#if swagger}}
9
+ @ApiTags("App")
10
+ {{/if}}
5
11
  @Controller()
6
12
  export class AppController {
7
13
  constructor(private readonly appService: AppService) {}
8
14
 
15
+ {{#if swagger}}
16
+ @ApiOperation({ summary: "/api" })
17
+ @ApiResponse({ status: 200, description: "Returns a hello world message" })
18
+ {{/if}}
9
19
  @Get()
10
20
  getHello(): string {
11
21
  return this.appService.getHello();
@@ -6,6 +6,15 @@ import { env } from "./config/env.js";
6
6
  {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
7
7
  import { AuthModule } from "./auth/auth.module.js";
8
8
  {{/if}}
9
+ {{#if hasTrpc}}
10
+ import { TRPCModule } from "nestjs-trpc";
11
+ import { AppRouterClass as AppRouter } from "./app.router.js";
12
+ import { AppContext } from "./libs/trpc/context.js";
13
+ import { AppErrorHandler } from "./libs/trpc/error.handler.js";
14
+ {{#if hasTrpcAndAuth}}
15
+ import { AuthTRPCMiddleware } from "./libs/middlewares/auth.trpc.middleware.js";
16
+ {{/if}}
17
+ {{/if}}
9
18
 
10
19
  import { AppController } from "./app.controller.js";
11
20
  import { AppService } from "./app.service.js";
@@ -24,7 +33,23 @@ import { AppService } from "./app.service.js";
24
33
  {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
25
34
  AuthModule,
26
35
  {{/if}}
36
+ {{#if hasTrpc}}
37
+ TRPCModule.forRoot({
38
+ context: AppContext,
39
+ onError: AppErrorHandler,
40
+ }),
41
+ {{/if}}
42
+ ],
43
+ providers: [
44
+ AppService,
45
+ {{#if hasTrpc}}
46
+ {{#if hasTrpcAndAuth}}
47
+ AuthTRPCMiddleware,
48
+ {{/if}}
49
+ AppContext,
50
+ AppErrorHandler,
51
+ AppRouter,
52
+ {{/if}}
27
53
  ],
28
- providers: [AppService],
29
54
  })
30
55
  export class AppModule {}
@@ -2,15 +2,88 @@ import { NestFactory } from "@nestjs/core";
2
2
  {{#if (eq httpProvider "fastify")}}
3
3
  import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
4
  {{/if}}
5
+ import { Logger } from "@nestjs/common";
5
6
  import { env } from "@repo/env/api-gateway";
6
7
 
7
8
  import { AppModule } from "./app.module.js";
9
+ {{#if swagger}}
10
+ import { createDocs } from "./docs/create-docs.js";
11
+ {{/if}}
12
+ {{#if (and swagger useSwaggerScalar)}}
13
+ import { apiReference } from "@scalar/nestjs-api-reference";
14
+ {{/if}}
15
+ {{#if (and swagger (eq useSwaggerScalar false))}}
16
+ import { SwaggerModule } from "@nestjs/swagger";
17
+ {{/if}}
18
+ {{#if (and swagger (or (eq auth "better-auth") (eq auth "better-auth:stateless")))}}
19
+ import { auth } from "./auth/auth.js";
20
+ {{/if}}
8
21
 
9
22
  async function bootstrap() {
10
23
  const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
11
24
  app.enableCors({
12
25
  origin: env.CORS_ORIGIN,
13
26
  });
27
+ {{#if swagger}}
28
+ const docsPath = "/docs";
29
+ {{#if useSwaggerScalar}}
30
+ app.use(
31
+ docsPath,
32
+ apiReference({
33
+ content: await createDocs(app, {
34
+ title: "{{projectNamePascalCase}} API",
35
+ description: "{{description}}",
36
+ version: "1.0.0",
37
+ integrations: {
38
+ {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
39
+ betterAuth: {
40
+ auth,
41
+ pathPrefix: "/api/auth",
42
+ },
43
+ {{/if}}
44
+ {{#if (includes apis "trpc")}}
45
+ trpc: {
46
+ routerFilePath: "./src/libs/trpc/@generated/server.ts",
47
+ pathPrefix: "/trpc",
48
+ },
49
+ {{/if}}
50
+ zod: {
51
+ withFastify: {{#if (eq httpProvider "fastify")}}true{{else}}false{{/if}},
52
+ },
53
+ },
54
+ }),
55
+ pageTitle: "{{projectNamePascalCase}} API Docs",
56
+ theme: "default",
57
+ }),
58
+ );
59
+ {{else}}
60
+ const document = await createDocs(app, {
61
+ title: "{{projectNamePascalCase}} API",
62
+ description: "{{description}}",
63
+ version: "1.0.0",
64
+ integrations: {
65
+ {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
66
+ betterAuth: {
67
+ auth,
68
+ pathPrefix: "/api/auth",
69
+ },
70
+ {{/if}}
71
+ {{#if (includes apis "trpc")}}
72
+ trpc: {
73
+ routerFilePath: "./src/trpc/router.ts",
74
+ pathPrefix: "/trpc",
75
+ },
76
+ {{/if}}
77
+ zod: {
78
+ withFastify: {{#if (eq httpProvider "fastify")}}true{{else}}false{{/if}},
79
+ },
80
+ },
81
+ });
82
+ SwaggerModule.setup(docsPath, app, document);
83
+ {{/if}}
84
+ Logger.log(`Swagger documentation available at http://localhost:${env.PORT ?? 3000}${docsPath}`, "SwaggerDocs");
85
+ {{/if}}
14
86
  await app.listen(env.PORT ?? 3000);
87
+ Logger.log(`Started backend server on http://localhost:${env.PORT ?? 3000}/api`, "Main");
15
88
  }
16
89
  await bootstrap();
@@ -4,6 +4,9 @@ packages:
4
4
  allowBuilds:
5
5
  '@nestjs/core': true
6
6
  esbuild: true
7
+ {{#if swagger}}
8
+ '@scarf/scarf': true
9
+ {{/if}}
7
10
  catalog:
8
11
  "@types/node": ^22.13.14
9
12
  dotenv: ^17.2.2
@@ -1,4 +1,7 @@
1
1
  allowBuilds:
2
2
  "@nestjs/core": true
3
+ {{#if swagger}}
4
+ "@scarf/scarf": true
5
+ {{/if}}
3
6
  catalog:
4
7
  dotenv: ^17.2.2
@@ -2,9 +2,22 @@ import { NestFactory } from "@nestjs/core";
2
2
  {{#if (eq httpProvider "fastify")}}
3
3
  import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
4
  {{/if}}
5
+ import { Logger } from "@nestjs/common";
5
6
 
6
7
  import { AppModule } from "./app.module.js";
7
8
  import { env } from "./config/env.js";
9
+ {{#if swagger}}
10
+ import { createDocs } from "./docs/create-docs.js";
11
+ {{/if}}
12
+ {{#if (and swagger useSwaggerScalar)}}
13
+ import { apiReference } from "@scalar/nestjs-api-reference";
14
+ {{/if}}
15
+ {{#if (and swagger (eq useSwaggerScalar false))}}
16
+ import { SwaggerModule } from "@nestjs/swagger";
17
+ {{/if}}
18
+ {{#if (and swagger (or (eq auth "better-auth") (eq auth "better-auth:stateless")))}}
19
+ import { auth } from "./auth/auth.js";
20
+ {{/if}}
8
21
 
9
22
  async function bootstrap() {
10
23
  const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
@@ -12,7 +25,67 @@ async function bootstrap() {
12
25
  origin: env.CORS_ORIGIN,
13
26
  });
14
27
  app.setGlobalPrefix("api");
28
+ {{#if swagger}}
29
+ const docsPath = "/docs";
30
+ {{#if useSwaggerScalar}}
31
+ app.use(
32
+ docsPath,
33
+ apiReference({
34
+ content: await createDocs(app, {
35
+ title: "{{projectNamePascalCase}} API",
36
+ description: "{{description}}",
37
+ version: "1.0.0",
38
+ integrations: {
39
+ {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
40
+ betterAuth: {
41
+ auth,
42
+ pathPrefix: "/api/auth",
43
+ },
44
+ {{/if}}
45
+ {{#if (includes apis "trpc")}}
46
+ trpc: {
47
+ routerFilePath: "./src/trpc/router.ts",
48
+ pathPrefix: "/trpc",
49
+ },
50
+ {{/if}}
51
+ zod: {
52
+ withFastify: {{#if (eq httpProvider "fastify")}}true{{else}}false{{/if}},
53
+ },
54
+ },
55
+ }),
56
+ pageTitle: "{{projectNamePascalCase}} API Docs",
57
+ theme: "default",
58
+ }),
59
+ );
60
+ {{else}}
61
+ const document = await createDocs(app, {
62
+ title: "{{projectNamePascalCase}} API",
63
+ description: "{{description}}",
64
+ version: "1.0.0",
65
+ integrations: {
66
+ {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
67
+ betterAuth: {
68
+ auth,
69
+ pathPrefix: "/api/auth",
70
+ },
71
+ {{/if}}
72
+ {{#if (includes apis "trpc")}}
73
+ trpc: {
74
+ routerFilePath: "./src/trpc/router.ts",
75
+ pathPrefix: "/trpc",
76
+ },
77
+ {{/if}}
78
+ zod: {
79
+ withFastify: {{#if (eq httpProvider "fastify")}}true{{else}}false{{/if}},
80
+ },
81
+ },
82
+ });
83
+ SwaggerModule.setup(docsPath, app, document);
84
+ {{/if}}
85
+ Logger.log(`Swagger documentation available at http://localhost:${env.PORT ?? 3000}${docsPath}`, "SwaggerDocs");
86
+ {{/if}}
15
87
 
16
88
  await app.listen(env.PORT ?? 3000);
89
+ Logger.log(`Started backend server on http://localhost:${env.PORT ?? 3000}/api`, "Main");
17
90
  }
18
91
  await bootstrap();
@@ -2,9 +2,22 @@ import { NestFactory } from "@nestjs/core";
2
2
  {{#if (eq httpProvider "fastify")}}
3
3
  import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
4
  {{/if}}
5
+ import { Logger } from "@nestjs/common";
5
6
 
6
7
  import { AppModule } from "./app.module.js";
7
8
  import { env } from "./config/env.js";
9
+ {{#if swagger}}
10
+ import { createDocs } from "./docs/create-docs.js";
11
+ {{/if}}
12
+ {{#if (and swagger useSwaggerScalar)}}
13
+ import { apiReference } from "@scalar/nestjs-api-reference";
14
+ {{/if}}
15
+ {{#if (and swagger (eq useSwaggerScalar false))}}
16
+ import { SwaggerModule } from "@nestjs/swagger";
17
+ {{/if}}
18
+ {{#if (and swagger (or (eq auth "better-auth") (eq auth "better-auth:stateless")))}}
19
+ import { auth } from "./auth/auth.js";
20
+ {{/if}}
8
21
 
9
22
  async function bootstrap() {
10
23
  const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
@@ -12,7 +25,67 @@ async function bootstrap() {
12
25
  origin: env.CORS_ORIGIN,
13
26
  });
14
27
  app.setGlobalPrefix("api");
28
+ {{#if swagger}}
29
+ const docsPath = "/docs";
30
+ {{#if useSwaggerScalar}}
31
+ app.use(
32
+ docsPath,
33
+ apiReference({
34
+ content: await createDocs(app, {
35
+ title: "{{projectNamePascalCase}} API",
36
+ description: "{{description}}",
37
+ version: "1.0.0",
38
+ integrations: {
39
+ {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
40
+ betterAuth: {
41
+ auth,
42
+ pathPrefix: "/api/auth",
43
+ },
44
+ {{/if}}
45
+ {{#if (includes apis "trpc")}}
46
+ trpc: {
47
+ routerFilePath: "./src/trpc/router.ts",
48
+ pathPrefix: "/trpc",
49
+ },
50
+ {{/if}}
51
+ zod: {
52
+ withFastify: {{#if (eq httpProvider "fastify")}}true{{else}}false{{/if}},
53
+ },
54
+ },
55
+ }),
56
+ pageTitle: "{{projectNamePascalCase}} API Docs",
57
+ theme: "default",
58
+ }),
59
+ );
60
+ {{else}}
61
+ const document = await createDocs(app, {
62
+ title: "{{projectNamePascalCase}} API",
63
+ description: "{{description}}",
64
+ version: "1.0.0",
65
+ integrations: {
66
+ {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
67
+ betterAuth: {
68
+ auth,
69
+ pathPrefix: "/api/auth",
70
+ },
71
+ {{/if}}
72
+ {{#if (includes apis "trpc")}}
73
+ trpc: {
74
+ routerFilePath: "./src/trpc/router.ts",
75
+ pathPrefix: "/trpc",
76
+ },
77
+ {{/if}}
78
+ zod: {
79
+ withFastify: {{#if (eq httpProvider "fastify")}}true{{else}}false{{/if}},
80
+ },
81
+ },
82
+ });
83
+ SwaggerModule.setup(docsPath, app, document);
84
+ {{/if}}
85
+ Logger.log(`Swagger documentation available at http://localhost:${env.PORT ?? 3000}${docsPath}`, "SwaggerDocs");
86
+ {{/if}}
15
87
 
16
88
  await app.listen(env.PORT ?? 3000);
89
+ Logger.log(`Started backend server on http://localhost:${env.PORT ?? 3000}/api`, "Main");
17
90
  }
18
91
  await bootstrap();
@@ -2,10 +2,23 @@ import { NestFactory } from "@nestjs/core";
2
2
  {{#if (eq httpProvider "fastify")}}
3
3
  import { FastifyAdapter, NestFastifyApplication } from "@nestjs/platform-fastify";
4
4
  {{/if}}
5
+ import { Logger } from "@nestjs/common";
5
6
  import { Transport, type MicroserviceOptions } from "@nestjs/microservices";
6
7
 
7
8
  import { AppModule } from "./app.module.js";
8
9
  import { env } from "./config/env.js";
10
+ {{#if swagger}}
11
+ import { createDocs } from "./docs/create-docs.js";
12
+ {{/if}}
13
+ {{#if (and swagger useSwaggerScalar)}}
14
+ import { apiReference } from "@scalar/nestjs-api-reference";
15
+ {{/if}}
16
+ {{#if (and swagger (eq useSwaggerScalar false))}}
17
+ import { SwaggerModule } from "@nestjs/swagger";
18
+ {{/if}}
19
+ {{#if (and swagger (or (eq auth "better-auth") (eq auth "better-auth:stateless")))}}
20
+ import { auth } from "./auth/auth.js";
21
+ {{/if}}
9
22
 
10
23
  async function bootstrap() {
11
24
  const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()){{else}}(AppModule){{/if}};
@@ -18,7 +31,68 @@ async function bootstrap() {
18
31
  },
19
32
  });
20
33
 
34
+ {{#if swagger}}
35
+ const docsPath = "/docs";
36
+ {{#if useSwaggerScalar}}
37
+ app.use(
38
+ docsPath,
39
+ apiReference({
40
+ content: await createDocs(app, {
41
+ title: "{{projectNamePascalCase}} API",
42
+ description: "{{description}}",
43
+ version: "1.0.0",
44
+ integrations: {
45
+ {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
46
+ betterAuth: {
47
+ auth,
48
+ pathPrefix: "/api/auth",
49
+ },
50
+ {{/if}}
51
+ {{#if (includes apis "trpc")}}
52
+ trpc: {
53
+ routerFilePath: "./src/trpc/router.ts",
54
+ pathPrefix: "/trpc",
55
+ },
56
+ {{/if}}
57
+ zod: {
58
+ withFastify: {{#if (eq httpProvider "fastify")}}true{{else}}false{{/if}},
59
+ },
60
+ },
61
+ }),
62
+ pageTitle: "{{projectNamePascalCase}} API Docs",
63
+ theme: "default",
64
+ }),
65
+ );
66
+ {{else}}
67
+ const document = await createDocs(app, {
68
+ title: "{{projectNamePascalCase}} API",
69
+ description: "{{description}}",
70
+ version: "1.0.0",
71
+ integrations: {
72
+ {{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
73
+ betterAuth: {
74
+ auth,
75
+ pathPrefix: "/api/auth",
76
+ },
77
+ {{/if}}
78
+ {{#if (includes apis "trpc")}}
79
+ trpc: {
80
+ routerFilePath: "./src/trpc/router.ts",
81
+ pathPrefix: "/trpc",
82
+ },
83
+ {{/if}}
84
+ zod: {
85
+ withFastify: {{#if (eq httpProvider "fastify")}}true{{else}}false{{/if}},
86
+ },
87
+ },
88
+ });
89
+ SwaggerModule.setup(docsPath, app, document);
90
+ {{/if}}
91
+ Logger.log(`Swagger documentation available at http://localhost:${env.PORT ?? 3000}${docsPath}`, "SwaggerDocs");
92
+ {{/if}}
93
+
21
94
  await app.startAllMicroservices();
22
95
  await app.listen(env.PORT ?? 3000);
96
+ Logger.log(`Started backend server on http://localhost:${env.PORT ?? 3000}/api`, "Main");
23
97
  }
24
98
  await bootstrap();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-arch/tui",
3
- "version": "0.1.48",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "description": "Interactive terminal UI for generating NestJS projects",
6
6
  "keywords": [
@@ -49,8 +49,8 @@
49
49
  "tsx": "^4.19.2",
50
50
  "vitest": "^4.1.7",
51
51
  "@nest-arch/env": "0.0.0",
52
- "@nest-arch/shared": "0.0.0",
53
- "@nest-arch/core": "0.1.48"
52
+ "@nest-arch/core": "0.2.0",
53
+ "@nest-arch/shared": "0.0.0"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "typescript": "^5"
@@ -1 +0,0 @@
1
- const O="Nest Arch",A="v0.1.48",t="The comfy way to build NestJS projects",o="#e54545",R="#A0A0A0",c="#6B6B6B",s="#E5E5E5",C="#61AFEF",E="#3A3A3A",_="#7FD99A",n="#E8C468",L="#e96142ff";export{O as APP_NAME,t as APP_TAGLINE,A as APP_VERSION,C as COLOR_ACCENT,R as COLOR_DIM,c as COLOR_DIMMER,E as COLOR_DIVIDER,s as COLOR_FG,o as COLOR_RED,_ as COLOR_SUCCESS,n as COLOR_WARM,L as COLOR_WARM_SECONDARY};