tspace-spear 1.2.5 → 1.2.6
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/README.md +300 -26
- package/dist/cli/app.d.ts +1 -0
- package/dist/cli/app.js +24 -0
- package/dist/cli/app.js.map +1 -0
- package/dist/cli/controller.d.ts +1 -0
- package/dist/cli/controller.js +158 -0
- package/dist/cli/controller.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +138 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/lib/core/client/index.d.ts +82 -0
- package/dist/lib/core/client/index.js +142 -0
- package/dist/lib/core/client/index.js.map +1 -0
- package/dist/lib/core/compiler/generator.d.ts +18 -0
- package/dist/lib/core/compiler/generator.js +347 -0
- package/dist/lib/core/compiler/generator.js.map +1 -0
- package/dist/lib/core/compiler/index.d.ts +14 -0
- package/dist/lib/core/compiler/index.js +12 -0
- package/dist/lib/core/compiler/index.js.map +1 -0
- package/dist/lib/core/compiler/pre-routes.d.ts +165 -0
- package/dist/lib/core/compiler/pre-routes.js +48 -0
- package/dist/lib/core/compiler/pre-routes.js.map +1 -0
- package/dist/lib/core/compiler/types.d.ts +14 -0
- package/dist/lib/core/compiler/types.js +3 -0
- package/dist/lib/core/compiler/types.js.map +1 -0
- package/dist/lib/core/decorators/context.d.ts +50 -1
- package/dist/lib/core/decorators/context.js +87 -3
- package/dist/lib/core/decorators/context.js.map +1 -1
- package/dist/lib/core/decorators/swagger.d.ts +1 -1
- package/dist/lib/core/decorators/swagger.js +1 -1
- package/dist/lib/core/decorators/swagger.js.map +1 -1
- package/dist/lib/core/server/fast-router.js +11 -2
- package/dist/lib/core/server/fast-router.js.map +1 -1
- package/dist/lib/core/server/index.d.ts +16 -0
- package/dist/lib/core/server/index.js +118 -38
- package/dist/lib/core/server/index.js.map +1 -1
- package/dist/lib/core/server/parser-factory.d.ts +2 -2
- package/dist/lib/core/server/parser-factory.js +236 -4
- package/dist/lib/core/server/parser-factory.js.map +1 -1
- package/dist/lib/core/types/index.d.ts +13 -9
- package/dist/tests/e2e..test.d.ts +1 -0
- package/dist/tests/e2e..test.js +16 -0
- package/dist/tests/e2e..test.js.map +1 -0
- package/package.json +32 -4
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const app_1 = require("./app");
|
|
10
|
+
const controller_1 = require("./controller");
|
|
11
|
+
const [, , action, type, target] = process.argv;
|
|
12
|
+
switch (`${action}:${type}`) {
|
|
13
|
+
case "create:app":
|
|
14
|
+
createApp(target);
|
|
15
|
+
break;
|
|
16
|
+
case "create:controller":
|
|
17
|
+
createController(target);
|
|
18
|
+
break;
|
|
19
|
+
default:
|
|
20
|
+
console.log(`
|
|
21
|
+
Usage:
|
|
22
|
+
|
|
23
|
+
tspace-spear create app ./src
|
|
24
|
+
tspace-spear create controller cats
|
|
25
|
+
`);
|
|
26
|
+
}
|
|
27
|
+
function createApp(targetPath) {
|
|
28
|
+
if (!targetPath) {
|
|
29
|
+
console.log("Missing target path");
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
const root = path_1.default.resolve(process.cwd(), targetPath);
|
|
33
|
+
fs_1.default.mkdirSync(root, {
|
|
34
|
+
recursive: true
|
|
35
|
+
});
|
|
36
|
+
fs_1.default.mkdirSync(path_1.default.join(root, "controllers"), {
|
|
37
|
+
recursive: true
|
|
38
|
+
});
|
|
39
|
+
fs_1.default.writeFileSync(path_1.default.join(root, "index.ts"), app_1.app);
|
|
40
|
+
fs_1.default.writeFileSync(path_1.default.join(root, "controllers", "cat.controller.ts"), controller_1.CatController);
|
|
41
|
+
console.log(`App created at: ${root}`);
|
|
42
|
+
}
|
|
43
|
+
function createController(name) {
|
|
44
|
+
if (!name) {
|
|
45
|
+
console.log("Missing controller name");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
const fileName = `${name}.controller.ts`;
|
|
49
|
+
const target = path_1.default.resolve(process.cwd(), "controllers", fileName);
|
|
50
|
+
fs_1.default.mkdirSync(path_1.default.dirname(target), {
|
|
51
|
+
recursive: true
|
|
52
|
+
});
|
|
53
|
+
const className = capitalize(name) + "Controller";
|
|
54
|
+
fs_1.default.writeFileSync(target, `
|
|
55
|
+
import {
|
|
56
|
+
type T,
|
|
57
|
+
Controller,
|
|
58
|
+
Get,
|
|
59
|
+
Post,
|
|
60
|
+
Put,
|
|
61
|
+
Delete
|
|
62
|
+
} from "tspace-spear";
|
|
63
|
+
|
|
64
|
+
@Controller("/${name}")
|
|
65
|
+
export default class ${className} {
|
|
66
|
+
|
|
67
|
+
@Get("/")
|
|
68
|
+
async index() {
|
|
69
|
+
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Get("/:id")
|
|
74
|
+
async show({
|
|
75
|
+
params
|
|
76
|
+
}: T.Context<{
|
|
77
|
+
params: {
|
|
78
|
+
id: number;
|
|
79
|
+
};
|
|
80
|
+
}>) {
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
id: params.id
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Post("/")
|
|
88
|
+
async create({
|
|
89
|
+
body
|
|
90
|
+
}: T.Context<{
|
|
91
|
+
body: {};
|
|
92
|
+
}>) {
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
body
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Put("/:id")
|
|
100
|
+
async update({
|
|
101
|
+
params,
|
|
102
|
+
body
|
|
103
|
+
}: T.Context<{
|
|
104
|
+
params: {
|
|
105
|
+
id: number;
|
|
106
|
+
};
|
|
107
|
+
body: {};
|
|
108
|
+
}>) {
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
id: params.id,
|
|
112
|
+
body
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@Delete("/:id")
|
|
117
|
+
async remove({
|
|
118
|
+
params
|
|
119
|
+
}: T.Context<{
|
|
120
|
+
params: {
|
|
121
|
+
id: number;
|
|
122
|
+
};
|
|
123
|
+
}>) {
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
id: params.id
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
`);
|
|
132
|
+
console.log(`Controller created: ${fileName}`);
|
|
133
|
+
}
|
|
134
|
+
function capitalize(value) {
|
|
135
|
+
return (value.charAt(0).toUpperCase() +
|
|
136
|
+
value.slice(1));
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;AAEA,4CAAoB;AACpB,gDAAwB;AACxB,+BAA4B;AAC5B,6CAA6C;AAE7C,MAAM,CAAC,EAAE,AAAD,EAAG,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;AAEhD,QAAQ,GAAG,MAAM,IAAI,IAAI,EAAE,EAAE,CAAC;IAE5B,KAAK,YAAY;QACf,SAAS,CAAC,MAAM,CAAC,CAAC;QAClB,MAAM;IAER,KAAK,mBAAmB;QACtB,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACzB,MAAM;IAER;QACE,OAAO,CAAC,GAAG,CAAC;;;;;CAKf,CAAC,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,UAAmB;IAEpC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,CAAC,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V;;;;;;;;;;gBAUgB,IAAI;uBACG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkE/B,CACE,CAAC;IAEF,OAAO,CAAC,GAAG,CACT,uBAAuB,QAAQ,EAAE,CAClC,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,KAAa;IAEb,OAAO,CACL,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { AnyRoutes, RoutesWithMethod, RequestBody, RequestQuery, RequestParams, RequestFiles, ResponseType } from "../compiler/types";
|
|
2
|
+
type RequestInput<TRoutes extends AnyRoutes, TPath extends keyof TRoutes, TMethod extends keyof TRoutes[TPath]> = RequestParams<TRoutes, TPath, TMethod> extends never ? {
|
|
3
|
+
params?: never;
|
|
4
|
+
query?: RequestQuery<TRoutes, TPath, TMethod>;
|
|
5
|
+
body?: RequestBody<TRoutes, TPath, TMethod>;
|
|
6
|
+
files?: RequestFiles<TRoutes, TPath, TMethod>;
|
|
7
|
+
} : {
|
|
8
|
+
params: RequestParams<TRoutes, TPath, TMethod>;
|
|
9
|
+
query?: RequestQuery<TRoutes, TPath, TMethod>;
|
|
10
|
+
body?: RequestBody<TRoutes, TPath, TMethod>;
|
|
11
|
+
files?: RequestFiles<TRoutes, TPath, TMethod>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Type-safe HTTP client built on top of the native Fetch API.
|
|
15
|
+
*
|
|
16
|
+
* `ApiClient` provides end-to-end type safety for your API routes,
|
|
17
|
+
* including:
|
|
18
|
+
*
|
|
19
|
+
* - `params` typing
|
|
20
|
+
* - `query` typing
|
|
21
|
+
* - `body` typing
|
|
22
|
+
* - typed file uploads
|
|
23
|
+
* - fully inferred response types
|
|
24
|
+
*
|
|
25
|
+
* Route types are inferred from your server route definitions,
|
|
26
|
+
* giving you autocomplete and compile-time validation across
|
|
27
|
+
* the entire request lifecycle.
|
|
28
|
+
*
|
|
29
|
+
* @template TRoutes Application route definitions.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import app from '../server/app';
|
|
34
|
+
*
|
|
35
|
+
* const client = new ApiClient<typeof app.contract>()
|
|
36
|
+
*
|
|
37
|
+
* const res = await client.get("/cats", {
|
|
38
|
+
* query: {
|
|
39
|
+
* id: "1",
|
|
40
|
+
* },
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* // fully typed response
|
|
44
|
+
* console.log(res.cats)
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare class ApiClient<TRoutes extends AnyRoutes> {
|
|
48
|
+
private baseURL;
|
|
49
|
+
constructor(baseURL: string);
|
|
50
|
+
protected request<TPath extends keyof TRoutes, TMethod extends keyof TRoutes[TPath]>(method: TMethod, path: TPath, input?: RequestInput<TRoutes, TPath, TMethod>): Promise<{
|
|
51
|
+
ok: boolean;
|
|
52
|
+
status: number;
|
|
53
|
+
data: ResponseType<TRoutes, TPath, TMethod>;
|
|
54
|
+
}>;
|
|
55
|
+
get<TPath extends RoutesWithMethod<TRoutes, "GET">>(path: TPath, input?: RequestInput<TRoutes, TPath, "GET">): Promise<{
|
|
56
|
+
ok: boolean;
|
|
57
|
+
status: number;
|
|
58
|
+
data: ResponseType<TRoutes, TPath, "GET">;
|
|
59
|
+
}>;
|
|
60
|
+
post<TPath extends RoutesWithMethod<TRoutes, "POST">>(path: TPath, input: RequestInput<TRoutes, TPath, "POST">): Promise<{
|
|
61
|
+
ok: boolean;
|
|
62
|
+
status: number;
|
|
63
|
+
data: ResponseType<TRoutes, TPath, "POST">;
|
|
64
|
+
}>;
|
|
65
|
+
put<TPath extends RoutesWithMethod<TRoutes, "PUT">>(path: TPath, input: RequestInput<TRoutes, TPath, "PUT">): Promise<{
|
|
66
|
+
ok: boolean;
|
|
67
|
+
status: number;
|
|
68
|
+
data: ResponseType<TRoutes, TPath, "PUT">;
|
|
69
|
+
}>;
|
|
70
|
+
patch<TPath extends RoutesWithMethod<TRoutes, "PATCH">>(path: TPath, input: RequestInput<TRoutes, TPath, "PATCH">): Promise<{
|
|
71
|
+
ok: boolean;
|
|
72
|
+
status: number;
|
|
73
|
+
data: ResponseType<TRoutes, TPath, "PATCH">;
|
|
74
|
+
}>;
|
|
75
|
+
delete<TPath extends RoutesWithMethod<TRoutes, "DELETE">>(path: TPath, input?: RequestInput<TRoutes, TPath, "DELETE">): Promise<{
|
|
76
|
+
ok: boolean;
|
|
77
|
+
status: number;
|
|
78
|
+
data: ResponseType<TRoutes, TPath, "DELETE">;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
export { ApiClient };
|
|
82
|
+
export default ApiClient;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ApiClient = void 0;
|
|
27
|
+
let fetchFn = null;
|
|
28
|
+
async function getFetch() {
|
|
29
|
+
if (fetchFn)
|
|
30
|
+
return fetchFn;
|
|
31
|
+
if (globalThis.fetch) {
|
|
32
|
+
fetchFn = globalThis.fetch;
|
|
33
|
+
return fetchFn;
|
|
34
|
+
}
|
|
35
|
+
const mod = await Promise.resolve().then(() => __importStar(require("node-fetch")));
|
|
36
|
+
fetchFn = mod.default;
|
|
37
|
+
return fetchFn;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Type-safe HTTP client built on top of the native Fetch API.
|
|
41
|
+
*
|
|
42
|
+
* `ApiClient` provides end-to-end type safety for your API routes,
|
|
43
|
+
* including:
|
|
44
|
+
*
|
|
45
|
+
* - `params` typing
|
|
46
|
+
* - `query` typing
|
|
47
|
+
* - `body` typing
|
|
48
|
+
* - typed file uploads
|
|
49
|
+
* - fully inferred response types
|
|
50
|
+
*
|
|
51
|
+
* Route types are inferred from your server route definitions,
|
|
52
|
+
* giving you autocomplete and compile-time validation across
|
|
53
|
+
* the entire request lifecycle.
|
|
54
|
+
*
|
|
55
|
+
* @template TRoutes Application route definitions.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import app from '../server/app';
|
|
60
|
+
*
|
|
61
|
+
* const client = new ApiClient<typeof app.contract>()
|
|
62
|
+
*
|
|
63
|
+
* const res = await client.get("/cats", {
|
|
64
|
+
* query: {
|
|
65
|
+
* id: "1",
|
|
66
|
+
* },
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* // fully typed response
|
|
70
|
+
* console.log(res.cats)
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
class ApiClient {
|
|
74
|
+
baseURL;
|
|
75
|
+
constructor(baseURL) {
|
|
76
|
+
this.baseURL = baseURL;
|
|
77
|
+
}
|
|
78
|
+
async request(method, path, input) {
|
|
79
|
+
let url = this.baseURL + path;
|
|
80
|
+
if (input?.params) {
|
|
81
|
+
for (const key in input.params) {
|
|
82
|
+
url = url.replace(`:${key}`, encodeURIComponent(input.params[key]));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (input?.query) {
|
|
86
|
+
const queryString = new URLSearchParams(input.query).toString();
|
|
87
|
+
if (queryString) {
|
|
88
|
+
url += `?${queryString}`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
fetchFn = await getFetch();
|
|
92
|
+
if (!fetchFn) {
|
|
93
|
+
throw new Error("Fetch is not available. Use Node 18+ or polyfill.");
|
|
94
|
+
}
|
|
95
|
+
const res = await fetchFn(url, {
|
|
96
|
+
method: method,
|
|
97
|
+
headers: {
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
},
|
|
100
|
+
body: input?.body
|
|
101
|
+
? JSON.stringify(input.body)
|
|
102
|
+
: undefined,
|
|
103
|
+
});
|
|
104
|
+
const contentType = res.headers.get("content-type");
|
|
105
|
+
const isJson = contentType?.includes("application/json");
|
|
106
|
+
const data = isJson
|
|
107
|
+
? await res.json()
|
|
108
|
+
: await res.text();
|
|
109
|
+
// if (!res.ok) {
|
|
110
|
+
// throw new Error(
|
|
111
|
+
// data?.message ||
|
|
112
|
+
// data?.error ||
|
|
113
|
+
// (typeof data === "string"
|
|
114
|
+
// ? data
|
|
115
|
+
// : `HTTP ${res.status}`),
|
|
116
|
+
// );
|
|
117
|
+
// }
|
|
118
|
+
return {
|
|
119
|
+
ok: res.ok,
|
|
120
|
+
status: res.status,
|
|
121
|
+
data,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async get(path, input) {
|
|
125
|
+
return this.request("GET", path, input);
|
|
126
|
+
}
|
|
127
|
+
async post(path, input) {
|
|
128
|
+
return this.request("POST", path, input);
|
|
129
|
+
}
|
|
130
|
+
async put(path, input) {
|
|
131
|
+
return this.request("PUT", path, input);
|
|
132
|
+
}
|
|
133
|
+
async patch(path, input) {
|
|
134
|
+
return this.request("PATCH", path, input);
|
|
135
|
+
}
|
|
136
|
+
async delete(path, input) {
|
|
137
|
+
return this.request("DELETE", path, input);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.ApiClient = ApiClient;
|
|
141
|
+
exports.default = ApiClient;
|
|
142
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAI,OAAO,GAAwB,IAAI,CAAC;AAExC,KAAK,UAAU,QAAQ;IACrB,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAE5B,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,GAAG,GAAG,wDAAa,YAAY,GAAC,CAAC;IACvC,OAAO,GAAG,GAAG,CAAC,OAAkC,CAAC;IAEjD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,SAAS;IAGL,OAAO,CAAS;IAExB,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAES,KAAK,CAAC,OAAO,CAIrB,MAAe,EACf,IAAW,EACX,KAIC;QAWC,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,GAAI,IAAe,CAAA;QAGzC,IAAI,KAAK,EAAE,MAAM,EAAE,CA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B;QACjB,mCAAmC;QACnC,OAAO;QACP,IAAI;QAEJ,OAAO;YACL,EAAE,EAAG,GAAG,CAAC,EAAE;YACX,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,IAAI;SACL,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,GAAG,CAMd,IAAW,EACX,KAIC;QAED,OAAO,IAAI,CAAC,OAAO,CACjB,KAAK,EACL,IAAI,EACJ,KAAK,CACN,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,IAAI,CAMf,IAAW,EACX,KAIC;QAED,OAAO,IAAI,CAAC,OAAO,CACjB,MAAM,EACN,IAAI,EACJ,KAAK,CACN,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,GAAG,CAMd,IAAW,EACX,KAIC;QAED,OAAO,IAAI,CAAC,OAAO,CACjB,KAAK,EACL,IAAI,EACJ,KAAK,CACN,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,KAAK,CAMhB,IAAW,EACX,KAIC;QAED,OAAO,IAAI,CAAC,OAAO,CACjB,OAAO,EACP,IAAI,EACJ,KAAK,CACN,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,MAAM,CAMjB,IAAW,EACX,KAIC;QAED,OAAO,IAAI,CAAC,OAAO,CACjB,QAAQ,EACR,IAAI,EACJ,KAAK,CACN,CAAC;IACJ,CAAC;CACF;AAEQ,8BAAS;AAClB,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type Route = {
|
|
2
|
+
method: string;
|
|
3
|
+
path: string;
|
|
4
|
+
response: string;
|
|
5
|
+
body: string;
|
|
6
|
+
params: string;
|
|
7
|
+
query: string;
|
|
8
|
+
files: string;
|
|
9
|
+
};
|
|
10
|
+
type Options = {
|
|
11
|
+
controllers: {
|
|
12
|
+
folder: string;
|
|
13
|
+
name: RegExp;
|
|
14
|
+
};
|
|
15
|
+
output?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function generateRoutes(options: Options): Promise<Route[] | undefined>;
|
|
18
|
+
export {};
|