-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnestia.config.ts
87 lines (82 loc) · 2.17 KB
/
nestia.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { NestFactory } from "@nestjs/core";
import * as sdk from "@nestia/sdk";
import "reflect-metadata";
import { OpenApi } from "@samchon/openapi";
import { StudioModule } from "./src/StudioModule";
import { ConnectorModule } from "./src/controllers/connector/ConnectorModule";
import { LoggerModule } from "nestjs-pino";
import { Type } from "@nestjs/common";
const toKebabCase = (str: string) => {
return str
.replace(/Module$/, "")
.replace(/([a-z])([A-Z])/g, "$1-$2")
.toLowerCase();
};
const swagger = (props: {
module: Type<any>;
info: Partial<OpenApi.IDocument.IInfo>;
output: string;
}): sdk.INestiaConfig => ({
input: () => NestFactory.create(props.module),
swagger: {
output: props.output,
info: props.info,
beautify: true,
decompose: true,
servers: [
{
url: "https://studio-connector-api.wrtn.ai",
description: "Production Server",
},
{
url: "https://studio-connector-poc.dev.wrtn.club",
description: "Develop Server",
},
{
url: "http://localhost:3003",
description: "Local Server",
},
],
},
});
const moduleNames = (
Reflect.getMetadata("imports", ConnectorModule) || []
).filter((module: any) => module !== LoggerModule);
const NESTIA_CONFIG: sdk.INestiaConfig[] = [
{
input: async () => NestFactory.create(StudioModule),
output: "src/api",
swagger: {
decompose: true,
output: "packages/api/swagger.json",
servers: [
{
url: "https://studio-connector-api.wrtn.ai",
description: "Production Server",
},
{
url: "https://studio-connector-poc.dev.wrtn.club",
description: "Develop Server",
},
{
url: "http://localhost:3003",
description: "Local Server",
},
],
beautify: true,
},
distribute: "packages/api",
simulate: true,
},
...moduleNames.map((module: any) => {
const title = toKebabCase(module.name);
return swagger({
module,
info: {
title: title,
},
output: `packages/api/connectors/${title}.swagger.json`,
});
}),
];
export default NESTIA_CONFIG;