@openapi-studio/nestjs 0.0.1
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi-studio.module.d.ts +82 -0
- package/dist/openapi-studio.module.d.ts.map +1 -0
- package/dist/openapi-studio.module.js +158 -0
- package/dist/openapi-studio.module.js.map +1 -0
- package/dist/utils/get-core-dist-path.util.d.ts +6 -0
- package/dist/utils/get-core-dist-path.util.d.ts.map +1 -0
- package/dist/utils/get-core-dist-path.util.js +23 -0
- package/dist/utils/get-core-dist-path.util.js.map +1 -0
- package/dist/utils/get-global-prefix.util.d.ts +6 -0
- package/dist/utils/get-global-prefix.util.d.ts.map +1 -0
- package/dist/utils/get-global-prefix.util.js +11 -0
- package/dist/utils/get-global-prefix.util.js.map +1 -0
- package/dist/utils/normalize-rel-path.util.d.ts +5 -0
- package/dist/utils/normalize-rel-path.util.d.ts.map +1 -0
- package/dist/utils/normalize-rel-path.util.js +22 -0
- package/dist/utils/normalize-rel-path.util.js.map +1 -0
- package/dist/utils/resolve-path.util.d.ts +7 -0
- package/dist/utils/resolve-path.util.d.ts.map +1 -0
- package/dist/utils/resolve-path.util.js +18 -0
- package/dist/utils/resolve-path.util.js.map +1 -0
- package/dist/utils/validate-global-prefix.util.d.ts +5 -0
- package/dist/utils/validate-global-prefix.util.d.ts.map +1 -0
- package/dist/utils/validate-global-prefix.util.js +10 -0
- package/dist/utils/validate-global-prefix.util.js.map +1 -0
- package/dist/utils/validate-path.util.d.ts +5 -0
- package/dist/utils/validate-path.util.d.ts.map +1 -0
- package/dist/utils/validate-path.util.js +18 -0
- package/dist/utils/validate-path.util.js.map +1 -0
- package/package.json +23 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { INestApplication } from '@nestjs/common';
|
|
2
|
+
import type { HttpServer } from '@nestjs/common';
|
|
3
|
+
import type { OpenAPIObject } from '@nestjs/swagger';
|
|
4
|
+
/**
|
|
5
|
+
* Options for OpenApiStudio setup
|
|
6
|
+
*/
|
|
7
|
+
export interface OpenApiStudioOptions {
|
|
8
|
+
/**
|
|
9
|
+
* URL path where the OpenAPI JSON document will be served
|
|
10
|
+
* @default '/openapi.json'
|
|
11
|
+
*/
|
|
12
|
+
jsonDocumentUrl?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Clerk publishable key for authentication
|
|
15
|
+
*/
|
|
16
|
+
clerkPublishableKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Service host URL for API requests
|
|
19
|
+
*/
|
|
20
|
+
serviceHost?: string;
|
|
21
|
+
/**
|
|
22
|
+
* OpenAPI spec URL (full URL to the OpenAPI JSON document)
|
|
23
|
+
* If not provided, will be constructed from serviceHost + jsonDocumentUrl
|
|
24
|
+
*/
|
|
25
|
+
openApiSpecUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether to use the global prefix
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
useGlobalPrefix?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Custom path to the static assets directory
|
|
33
|
+
* If not provided, will use the default from @openapi-studio/core
|
|
34
|
+
*/
|
|
35
|
+
customStaticPath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Custom path for the config.json file
|
|
38
|
+
* @default '/openapi-studio-config.json'
|
|
39
|
+
*/
|
|
40
|
+
configJsonPath?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @publicApi
|
|
44
|
+
*/
|
|
45
|
+
export declare class OpenApiStudioModule {
|
|
46
|
+
/**
|
|
47
|
+
* Sets up OpenApiStudio to serve the static application and OpenAPI document
|
|
48
|
+
* @param path - The path where OpenApiStudio will be served
|
|
49
|
+
* @param app - The NestJS application instance
|
|
50
|
+
* @param document - The OpenAPI document object
|
|
51
|
+
* @param options - Configuration options
|
|
52
|
+
*/
|
|
53
|
+
static setup(path: string, app: INestApplication, document: OpenAPIObject, options?: OpenApiStudioOptions): void;
|
|
54
|
+
/**
|
|
55
|
+
* Serves static assets from the core/dist directory
|
|
56
|
+
*/
|
|
57
|
+
protected static serveStatic(finalPath: string, app: INestApplication, customStaticPath?: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Serves the config.json file with the provided configuration
|
|
60
|
+
*/
|
|
61
|
+
protected static serveConfigJson(httpAdapter: HttpServer, configJsonPath: string, options: OpenApiStudioOptions): void;
|
|
62
|
+
/**
|
|
63
|
+
* Serves the OpenAPI document at the specified path
|
|
64
|
+
*/
|
|
65
|
+
protected static serveOpenApiDocument(httpAdapter: HttpServer, jsonDocumentUrl: string, document: OpenAPIObject): void;
|
|
66
|
+
/**
|
|
67
|
+
* Serves the index.html file for SPA routing
|
|
68
|
+
* This ensures that all routes under the finalPath serve the Vue app
|
|
69
|
+
*/
|
|
70
|
+
protected static serveIndexHtml(finalPath: string, httpAdapter: HttpServer): void;
|
|
71
|
+
/**
|
|
72
|
+
* Registers a catch-all route for SPA routing
|
|
73
|
+
* This should be called after all other routes are registered
|
|
74
|
+
* to ensure that any unmatched routes serve the Vue app
|
|
75
|
+
*
|
|
76
|
+
* @param setupPath - The path prefix where OpenApiStudio is served
|
|
77
|
+
* @param app - The NestJS application instance
|
|
78
|
+
* @param options - Configuration options (must match the options used in setup)
|
|
79
|
+
*/
|
|
80
|
+
static registerCatchAllRoute(setupPath: string, app: INestApplication, options?: OpenApiStudioOptions): void;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=openapi-studio.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-studio.module.d.ts","sourceRoot":"","sources":["../src/openapi-studio.module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AASrD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC5B;;;;;;OAMG;WACW,KAAK,CACf,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,oBAAoB;IA4ClC;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,WAAW,CACxB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,gBAAgB,EACrB,gBAAgB,CAAC,EAAE,MAAM;IAqB7B;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,eAAe,CAC5B,WAAW,EAAE,UAAU,EACvB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,oBAAoB;IAcjC;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,oBAAoB,CACjC,WAAW,EAAE,UAAU,EACvB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,aAAa;IAS3B;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,cAAc,CAC3B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,UAAU;IAgC3B;;;;;;;;OAQG;WACW,qBAAqB,CAC/B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,gBAAgB,EACrB,OAAO,CAAC,EAAE,oBAAoB;CA8BrC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { getGlobalPrefix } from './utils/get-global-prefix.util.js';
|
|
4
|
+
import { validateGlobalPrefix } from './utils/validate-global-prefix.util.js';
|
|
5
|
+
import { validatePath } from './utils/validate-path.util.js';
|
|
6
|
+
import { getCoreDistAbsoluteFSPath } from './utils/get-core-dist-path.util.js';
|
|
7
|
+
import { resolvePath } from './utils/resolve-path.util.js';
|
|
8
|
+
/**
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
11
|
+
export class OpenApiStudioModule {
|
|
12
|
+
/**
|
|
13
|
+
* Sets up OpenApiStudio to serve the static application and OpenAPI document
|
|
14
|
+
* @param path - The path where OpenApiStudio will be served
|
|
15
|
+
* @param app - The NestJS application instance
|
|
16
|
+
* @param document - The OpenAPI document object
|
|
17
|
+
* @param options - Configuration options
|
|
18
|
+
*/
|
|
19
|
+
static setup(path, app, document, options) {
|
|
20
|
+
console.log('options', options);
|
|
21
|
+
const globalPrefix = getGlobalPrefix(app);
|
|
22
|
+
const finalPath = validatePath(options?.useGlobalPrefix !== false && validateGlobalPrefix(globalPrefix)
|
|
23
|
+
? `${globalPrefix}${validatePath(path)}`
|
|
24
|
+
: path);
|
|
25
|
+
const validatedGlobalPrefix = options?.useGlobalPrefix !== false && validateGlobalPrefix(globalPrefix)
|
|
26
|
+
? validatePath(globalPrefix)
|
|
27
|
+
: '';
|
|
28
|
+
const jsonDocumentUrl = options?.jsonDocumentUrl
|
|
29
|
+
? `${validatedGlobalPrefix}${validatePath(options.jsonDocumentUrl)}`
|
|
30
|
+
: `${validatedGlobalPrefix}/openapi.json`;
|
|
31
|
+
console.log('jsonDocumentUrl', jsonDocumentUrl);
|
|
32
|
+
const configJsonPath = options?.configJsonPath
|
|
33
|
+
? `${validatedGlobalPrefix}${validatePath(options.configJsonPath)}`
|
|
34
|
+
: `${validatedGlobalPrefix}/openapi-studio-config.json`;
|
|
35
|
+
const httpAdapter = app.getHttpAdapter();
|
|
36
|
+
// Serve static files
|
|
37
|
+
OpenApiStudioModule.serveStatic(finalPath, app, options?.customStaticPath);
|
|
38
|
+
// Serve config.json
|
|
39
|
+
OpenApiStudioModule.serveConfigJson(httpAdapter, configJsonPath, options || {});
|
|
40
|
+
// Serve OpenAPI document
|
|
41
|
+
OpenApiStudioModule.serveOpenApiDocument(httpAdapter, jsonDocumentUrl, document);
|
|
42
|
+
// Serve the main HTML file for all routes (SPA routing)
|
|
43
|
+
OpenApiStudioModule.serveIndexHtml(finalPath, httpAdapter);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Serves static assets from the core/dist directory
|
|
47
|
+
*/
|
|
48
|
+
static serveStatic(finalPath, app, customStaticPath) {
|
|
49
|
+
const httpAdapter = app.getHttpAdapter();
|
|
50
|
+
const staticAssetsPath = customStaticPath
|
|
51
|
+
? resolvePath(customStaticPath)
|
|
52
|
+
: getCoreDistAbsoluteFSPath();
|
|
53
|
+
if (httpAdapter && httpAdapter.getType() === 'fastify') {
|
|
54
|
+
app.useStaticAssets({
|
|
55
|
+
root: staticAssetsPath,
|
|
56
|
+
prefix: finalPath,
|
|
57
|
+
decorateReply: false
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
app.useStaticAssets(staticAssetsPath, {
|
|
62
|
+
prefix: finalPath
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Serves the config.json file with the provided configuration
|
|
68
|
+
*/
|
|
69
|
+
static serveConfigJson(httpAdapter, configJsonPath, options) {
|
|
70
|
+
const normalizedPath = validatePath(configJsonPath);
|
|
71
|
+
httpAdapter.get(normalizedPath, (_req, res) => {
|
|
72
|
+
res.type('application/json');
|
|
73
|
+
const config = {
|
|
74
|
+
...(options.serviceHost && { serviceHost: options.serviceHost }),
|
|
75
|
+
...(options.clerkPublishableKey && { clerkKey: options.clerkPublishableKey }),
|
|
76
|
+
...(options.openApiSpecUrl && { openApiSpecUrl: options.openApiSpecUrl })
|
|
77
|
+
};
|
|
78
|
+
res.send(JSON.stringify(config));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Serves the OpenAPI document at the specified path
|
|
83
|
+
*/
|
|
84
|
+
static serveOpenApiDocument(httpAdapter, jsonDocumentUrl, document) {
|
|
85
|
+
const normalizedPath = validatePath(jsonDocumentUrl);
|
|
86
|
+
httpAdapter.get(normalizedPath, (_req, res) => {
|
|
87
|
+
res.type('application/json');
|
|
88
|
+
res.send(JSON.stringify(document));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Serves the index.html file for SPA routing
|
|
93
|
+
* This ensures that all routes under the finalPath serve the Vue app
|
|
94
|
+
*/
|
|
95
|
+
static serveIndexHtml(finalPath, httpAdapter) {
|
|
96
|
+
const distPath = getCoreDistAbsoluteFSPath();
|
|
97
|
+
const indexHtmlPath = path.join(distPath, 'index.html');
|
|
98
|
+
// Read index.html once
|
|
99
|
+
let indexHtml = null;
|
|
100
|
+
try {
|
|
101
|
+
indexHtml = fs.readFileSync(indexHtmlPath, 'utf-8');
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
console.warn(`Could not read index.html from ${indexHtmlPath}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const serveIndex = (_req, res) => {
|
|
108
|
+
res.type('text/html');
|
|
109
|
+
res.send(indexHtml);
|
|
110
|
+
};
|
|
111
|
+
// Serve index.html for the root path
|
|
112
|
+
httpAdapter.get(finalPath, serveIndex);
|
|
113
|
+
// Also serve for paths that might not match static files (SPA routing)
|
|
114
|
+
// This is a catch-all for the SPA - Vue Router will handle routing client-side
|
|
115
|
+
try {
|
|
116
|
+
const pathWithSlash = validatePath(`${finalPath}/`);
|
|
117
|
+
httpAdapter.get(pathWithSlash, serveIndex);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Ignore errors if route already exists
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Registers a catch-all route for SPA routing
|
|
125
|
+
* This should be called after all other routes are registered
|
|
126
|
+
* to ensure that any unmatched routes serve the Vue app
|
|
127
|
+
*
|
|
128
|
+
* @param setupPath - The path prefix where OpenApiStudio is served
|
|
129
|
+
* @param app - The NestJS application instance
|
|
130
|
+
* @param options - Configuration options (must match the options used in setup)
|
|
131
|
+
*/
|
|
132
|
+
static registerCatchAllRoute(setupPath, app, options) {
|
|
133
|
+
const globalPrefix = getGlobalPrefix(app);
|
|
134
|
+
const finalPath = validatePath(options?.useGlobalPrefix !== false && validateGlobalPrefix(globalPrefix)
|
|
135
|
+
? `${globalPrefix}${validatePath(setupPath)}`
|
|
136
|
+
: setupPath);
|
|
137
|
+
const httpAdapter = app.getHttpAdapter();
|
|
138
|
+
const distPath = getCoreDistAbsoluteFSPath();
|
|
139
|
+
const indexHtmlPath = path.join(distPath, 'index.html');
|
|
140
|
+
// Read index.html
|
|
141
|
+
let indexHtml = null;
|
|
142
|
+
try {
|
|
143
|
+
indexHtml = fs.readFileSync(indexHtmlPath, 'utf-8');
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
console.warn(`Could not read index.html from ${indexHtmlPath}`);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
// Register catch-all route for SPA
|
|
150
|
+
// This matches any route under finalPath that doesn't match a static file
|
|
151
|
+
const catchAllPattern = `${finalPath}/*`;
|
|
152
|
+
httpAdapter.get(catchAllPattern, (_req, res) => {
|
|
153
|
+
res.type('text/html');
|
|
154
|
+
res.send(indexHtml);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=openapi-studio.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-studio.module.js","sourceRoot":"","sources":["../src/openapi-studio.module.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AA+C3D;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAC5B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CACf,IAAY,EACZ,GAAqB,EACrB,QAAuB,EACvB,OAA8B;QAG9B,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,YAAY,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,YAAY,CAC1B,OAAO,EAAE,eAAe,KAAK,KAAK,IAAI,oBAAoB,CAAC,YAAY,CAAC;YACpE,CAAC,CAAC,GAAG,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE;YACxC,CAAC,CAAC,IAAI,CACb,CAAC;QACF,MAAM,qBAAqB,GACvB,OAAO,EAAE,eAAe,KAAK,KAAK,IAAI,oBAAoB,CAAC,YAAY,CAAC;YACpE,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;YAC5B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oBAAoB,CAAC,YAAY,CAAC;YACpE,CAAC,CAAC,GAAG,YAAY,GAAG,YAAY,CAAC,SAAS,CAAC,EAAE;YAC7C,CAAC,CAAC,SAAS,CAClB,CAAC;QAEF,MAAM,WAAW,GAAG,GAAG,CAAC,cAAc,EAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,yBAAyB,EAAE,CAAC;QAC7C,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAExD,kBAAkB;QAClB,IAAI,SAAS,GAAkB,IAAI,CAAC;QACpC,IAAI,CAAC;YACD,SAAS,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,kCAAkC,aAAa,EAAE,CAAC,CAAC;YAChE,OAAO;QACX,CAAC;QAED,mCAAmC;QACnC,0EAA0E;QAC1E,MAAM,eAAe,GAAG,GAAG,SAAS,IAAI,CAAC;QACzC,WAAW,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,IAAS,EAAE,GAAQ,EAAE,EAAE;YACrD,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACtB,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-core-dist-path.util.d.ts","sourceRoot":"","sources":["../../src/utils/get-core-dist-path.util.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAmBlD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the absolute filesystem path to the @openapi-studio/core dist directory
|
|
5
|
+
* Uses require.resolve to find the package location
|
|
6
|
+
*/
|
|
7
|
+
export function getCoreDistAbsoluteFSPath() {
|
|
8
|
+
try {
|
|
9
|
+
// Use createRequire to get require in ES module context
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
// Resolve the @openapi-studio/core package
|
|
12
|
+
const corePackagePath = require.resolve('@openapi-studio/core/package.json');
|
|
13
|
+
// Get the directory containing package.json
|
|
14
|
+
const corePackageDir = path.dirname(corePackagePath);
|
|
15
|
+
// Return the dist directory path
|
|
16
|
+
return path.join(corePackageDir, 'dist');
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw new Error(`Failed to resolve @openapi-studio/core package path. ` +
|
|
20
|
+
`Make sure @openapi-studio/core is installed. Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=get-core-dist-path.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-core-dist-path.util.js","sourceRoot":"","sources":["../../src/utils/get-core-dist-path.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,yBAAyB;IACrC,IAAI,CAAC;QACD,wDAAwD;QACxD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE/C,2CAA2C;QAC3C,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC;QAE7E,4CAA4C;QAC5C,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAErD,iCAAiC;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACX,uDAAuD;YACvD,uDAAuD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAClH,CAAC;IACN,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-global-prefix.util.d.ts","sourceRoot":"","sources":["../../src/utils/get-global-prefix.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAM7D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the global prefix from the NestJS application
|
|
3
|
+
*/
|
|
4
|
+
export function getGlobalPrefix(app) {
|
|
5
|
+
const config = app.config;
|
|
6
|
+
if (config && config.getGlobalPrefix) {
|
|
7
|
+
return config.getGlobalPrefix() || '';
|
|
8
|
+
}
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=get-global-prefix.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-global-prefix.util.js","sourceRoot":"","sources":["../../src/utils/get-global-prefix.util.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAqB;IACnD,MAAM,MAAM,GAAI,GAAW,CAAC,MAAM,CAAC;IACnC,IAAI,MAAM,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC;IACxC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-rel-path.util.d.ts","sourceRoot":"","sources":["../../src/utils/normalize-rel-path.util.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBrD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a relative path for use in URLs
|
|
3
|
+
*/
|
|
4
|
+
export function normalizeRelPath(path) {
|
|
5
|
+
if (!path) {
|
|
6
|
+
return './';
|
|
7
|
+
}
|
|
8
|
+
// Remove leading slash if present
|
|
9
|
+
if (path.startsWith('/')) {
|
|
10
|
+
path = path.slice(1);
|
|
11
|
+
}
|
|
12
|
+
// Ensure it ends with / if it's a directory
|
|
13
|
+
if (!path.endsWith('/') && !path.includes('.')) {
|
|
14
|
+
path = `${path}/`;
|
|
15
|
+
}
|
|
16
|
+
// Add ./ prefix for relative paths
|
|
17
|
+
if (!path.startsWith('./') && !path.startsWith('../')) {
|
|
18
|
+
path = `./${path}`;
|
|
19
|
+
}
|
|
20
|
+
return path;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=normalize-rel-path.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-rel-path.util.js","sourceRoot":"","sources":["../../src/utils/normalize-rel-path.util.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kCAAkC;IAClC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,4CAA4C;IAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC;IACpB,CAAC;IAED,mCAAmC;IACnC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a custom path to an absolute filesystem path
|
|
3
|
+
* @param customPath - The custom path to resolve (can be relative or absolute)
|
|
4
|
+
* @returns The absolute filesystem path
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolvePath(customPath: string): string;
|
|
7
|
+
//# sourceMappingURL=resolve-path.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-path.util.d.ts","sourceRoot":"","sources":["../../src/utils/resolve-path.util.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAYtD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a custom path to an absolute filesystem path
|
|
4
|
+
* @param customPath - The custom path to resolve (can be relative or absolute)
|
|
5
|
+
* @returns The absolute filesystem path
|
|
6
|
+
*/
|
|
7
|
+
export function resolvePath(customPath) {
|
|
8
|
+
if (typeof customPath !== 'string' || !customPath.trim()) {
|
|
9
|
+
throw new Error('Custom path must be a non-empty string');
|
|
10
|
+
}
|
|
11
|
+
// If it's already an absolute path, return it as-is
|
|
12
|
+
if (path.isAbsolute(customPath)) {
|
|
13
|
+
return customPath;
|
|
14
|
+
}
|
|
15
|
+
// Otherwise, resolve it relative to the current working directory
|
|
16
|
+
return path.resolve(process.cwd(), customPath);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=resolve-path.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-path.util.js","sourceRoot":"","sources":["../../src/utils/resolve-path.util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,UAAkB;IAC1C,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC9D,CAAC;IAED,oDAAoD;IACpD,IAAI,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,kEAAkE;IAClE,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-global-prefix.util.d.ts","sourceRoot":"","sources":["../../src/utils/validate-global-prefix.util.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAKlE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates that a global prefix is properly formatted
|
|
3
|
+
*/
|
|
4
|
+
export function validateGlobalPrefix(globalPrefix) {
|
|
5
|
+
if (!globalPrefix) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return globalPrefix.startsWith('/');
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=validate-global-prefix.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-global-prefix.util.js","sourceRoot":"","sources":["../../src/utils/validate-global-prefix.util.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAoB;IACvD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-path.util.d.ts","sourceRoot":"","sources":["../../src/utils/validate-path.util.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgBjD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates and normalizes a path string
|
|
3
|
+
*/
|
|
4
|
+
export function validatePath(path) {
|
|
5
|
+
if (typeof path !== 'string') {
|
|
6
|
+
throw new Error('Path must be a string');
|
|
7
|
+
}
|
|
8
|
+
// Ensure path starts with /
|
|
9
|
+
if (!path.startsWith('/')) {
|
|
10
|
+
path = `/${path}`;
|
|
11
|
+
}
|
|
12
|
+
// Remove trailing slash except for root
|
|
13
|
+
if (path.length > 1 && path.endsWith('/')) {
|
|
14
|
+
path = path.slice(0, -1);
|
|
15
|
+
}
|
|
16
|
+
return path;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=validate-path.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-path.util.js","sourceRoot":"","sources":["../../src/utils/validate-path.util.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,4BAA4B;IAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,wCAAwC;IACxC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1C,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openapi-studio/nestjs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -b -v"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@openapi-studio/core": "0.0.1",
|
|
12
|
+
"openapi-types": "^12.1.3"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@nestjs/common": "^11.0.0",
|
|
16
|
+
"@nestjs/core": "^11.0.0",
|
|
17
|
+
"@nestjs/platform-express": "^11.0.0",
|
|
18
|
+
"@nestjs/platform-fastify": "^11.0.0",
|
|
19
|
+
"@nestjs/swagger": "^11.2.3",
|
|
20
|
+
"@types/node": "^24.0.0",
|
|
21
|
+
"typescript": "^5.9.3"
|
|
22
|
+
}
|
|
23
|
+
}
|