phecda-server 1.0.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.
- package/LICENSE +21 -0
- package/dist/client/index.d.ts +27 -0
- package/dist/client/index.js +88 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +61 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.js +566 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +515 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types-6e2842b3.d.ts +47 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 fgsreally
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
import { R as RequestType, a as ResOrErr, P as PError } from '../types-6e2842b3.js';
|
|
3
|
+
|
|
4
|
+
interface RequestArgs {
|
|
5
|
+
body: Record<string, any>;
|
|
6
|
+
query: Record<string, string>;
|
|
7
|
+
params: Record<string, string>;
|
|
8
|
+
realParam: string;
|
|
9
|
+
method: RequestType;
|
|
10
|
+
url: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
type MergedReqArg = Pick<RequestArgs, 'body' | 'query' | 'params'>;
|
|
14
|
+
declare function toReq(arg: RequestArgs): {
|
|
15
|
+
method: RequestType;
|
|
16
|
+
url: string;
|
|
17
|
+
body: Record<string, any>;
|
|
18
|
+
query: string;
|
|
19
|
+
params: string;
|
|
20
|
+
};
|
|
21
|
+
declare const merge: (...args: RequestArgs[]) => Record<string, MergedReqArg>;
|
|
22
|
+
type RequestMethod = <F extends (...args: any[]) => any>(fn: F, args: Parameters<F>) => Promise<ReturnType<F>>;
|
|
23
|
+
declare function createReq(instance: AxiosInstance): <R>(arg: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<Awaited<R>>>;
|
|
24
|
+
declare function createMergeReq(instance: AxiosInstance, key?: string): <R extends unknown[]>(args: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<ResOrErr<R>>>;
|
|
25
|
+
declare function isError<T = any>(data: T | PError): data is PError;
|
|
26
|
+
|
|
27
|
+
export { RequestMethod, createMergeReq, createReq, isError, merge, toReq };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/client/index.ts
|
|
22
|
+
var client_exports = {};
|
|
23
|
+
__export(client_exports, {
|
|
24
|
+
createMergeReq: () => createMergeReq,
|
|
25
|
+
createReq: () => createReq,
|
|
26
|
+
isError: () => isError,
|
|
27
|
+
merge: () => merge,
|
|
28
|
+
toReq: () => toReq
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(client_exports);
|
|
31
|
+
function toReq(arg) {
|
|
32
|
+
const { body, query, realParam, method, url } = arg;
|
|
33
|
+
return {
|
|
34
|
+
method,
|
|
35
|
+
url,
|
|
36
|
+
body,
|
|
37
|
+
query: Object.keys(query).length > 0 ? `?${Object.entries(query).map(([k, v]) => `${k}=${v}`).join("&")}` : "",
|
|
38
|
+
params: realParam
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
__name(toReq, "toReq");
|
|
42
|
+
var merge = /* @__PURE__ */ __name((...args) => {
|
|
43
|
+
const ret = {};
|
|
44
|
+
for (const i of args) {
|
|
45
|
+
const { name, body, query, params } = i;
|
|
46
|
+
ret[name] = {
|
|
47
|
+
body,
|
|
48
|
+
query,
|
|
49
|
+
params
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return ret;
|
|
53
|
+
}, "merge");
|
|
54
|
+
function createReq(instance) {
|
|
55
|
+
return (arg, config) => {
|
|
56
|
+
const { url, params, query, body, method } = toReq(arg);
|
|
57
|
+
if (!method) {
|
|
58
|
+
console.warn("methods without route decorator won't send request");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const ret = [
|
|
62
|
+
`${url}${params}${query}`
|
|
63
|
+
];
|
|
64
|
+
body && ret.push(body);
|
|
65
|
+
config && ret.push(config);
|
|
66
|
+
return instance[method](...ret);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
__name(createReq, "createReq");
|
|
70
|
+
function createMergeReq(instance, key = "/__PHECDA_SERVER__") {
|
|
71
|
+
return (args, config) => {
|
|
72
|
+
return instance.post(key, merge(...args), config);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
__name(createMergeReq, "createMergeReq");
|
|
76
|
+
function isError(data) {
|
|
77
|
+
return typeof data === "object" && data.error;
|
|
78
|
+
}
|
|
79
|
+
__name(isError, "isError");
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
createMergeReq,
|
|
83
|
+
createReq,
|
|
84
|
+
isError,
|
|
85
|
+
merge,
|
|
86
|
+
toReq
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport type { PError, RequestType, ResOrErr } from '../types'\ninterface RequestArgs {\n body: Record<string, any>\n query: Record<string, string>\n params: Record<string, string>\n realParam: string\n method: RequestType\n url: string\n name: string\n}\ntype MergedReqArg = Pick<RequestArgs, 'body' | 'query' | 'params'>\nexport function toReq(arg: RequestArgs) {\n const { body, query, realParam, method, url } = arg\n return { method, url, body, query: Object.keys(query).length > 0 ? `?${Object.entries(query).map(([k, v]) => `${k}=${v}`).join('&')}` : '', params: realParam }\n}\n\nexport const merge = (...args: RequestArgs[]) => {\n const ret = {} as Record<string, MergedReqArg>\n for (const i of args) {\n const { name, body, query, params } = i\n ret[name] = { body, query, params }\n }\n\n return ret\n}\n\nexport type RequestMethod = <F extends (...args: any[]) => any >(fn: F, args: Parameters<F>) => Promise<ReturnType<F>>\n\nexport function createReq(instance: AxiosInstance): <R>(arg: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<Awaited<R>> > {\n // @ts-expect-error methods without route decorator won't send request\n return (arg: any, config?: AxiosRequestConfig) => {\n const { url, params, query, body, method } = toReq(arg as RequestArgs)\n if (!method) {\n console.warn('methods without route decorator won\\'t send request')\n return\n }\n\n const ret = [`${url}${params}${query}`] as any[]\n body && ret.push(body)\n config && ret.push(config)\n // @ts-expect-error misdirction\n return instance[method](...ret)\n }\n}\n\nexport function createMergeReq(instance: AxiosInstance, key = '/__PHECDA_SERVER__'): < R extends unknown[]>(args: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<ResOrErr<R>>> {\n // @ts-expect-error misdirction\n return (args: RequestArgs[], config?: AxiosRequestConfig) => {\n return instance.post(key, merge(...args), config)\n }\n}\n\nexport function isError<T = any>(data: T | PError): data is PError {\n return typeof data === 'object' && (data as any).error\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA;;;;;;;;;AAAO,SAASA,MAAMC,KAAkB;AACtC,QAAM,EAAEC,MAAMC,OAAOC,WAAWC,QAAQC,IAAG,IAAKL;AAChD,SAAO;IAAEI;IAAQC;IAAKJ;IAAMC,OAAOI,OAAOC,KAAKL,KAAAA,EAAOM,SAAS,IAAI,IAAIF,OAAOG,QAAQP,KAAAA,EAAOQ,IAAI,CAAC,CAACC,GAAGC,CAAAA,MAAO,GAAGD,KAAKC,GAAG,EAAEC,KAAK,GAAA,MAAS;IAAIC,QAAQX;EAAU;AAChK;AAHgBJ;AAKT,IAAMgB,QAAQ,2BAAIC,SAAwB;AAC/C,QAAMC,MAAM,CAAC;AACb,aAAWC,KAAKF,MAAM;AACpB,UAAM,EAAEG,MAAMlB,MAAMC,OAAOY,OAAM,IAAKI;AACtCD,QAAIE,QAAQ;MAAElB;MAAMC;MAAOY;IAAO;EACpC;AAEA,SAAOG;AACT,GARqB;AAYd,SAASG,UAAUC,UAA0G;AAElI,SAAO,CAACrB,KAAUsB,WAAgC;AAChD,UAAM,EAAEjB,KAAKS,QAAQZ,OAAOD,MAAMG,OAAM,IAAKL,MAAMC,GAAAA;AACnD,QAAI,CAACI,QAAQ;AACXmB,cAAQC,KAAK,oDAAA;AACb;IACF;AAEA,UAAMP,MAAM;MAAC,GAAGZ,MAAMS,SAASZ;;AAC/BD,YAAQgB,IAAIQ,KAAKxB,IAAAA;AACjBqB,cAAUL,IAAIQ,KAAKH,MAAAA;AAEnB,WAAOD,SAASjB,QAAO,GAAIa,GAAAA;EAC7B;AACF;AAfgBG;AAiBT,SAASM,eAAeL,UAAyBM,MAAM,sBAA2H;AAEvL,SAAO,CAACX,MAAqBM,WAAgC;AAC3D,WAAOD,SAASO,KAAKD,KAAKZ,MAAAA,GAASC,IAAAA,GAAOM,MAAAA;EAC5C;AACF;AALgBI;AAOT,SAASG,QAAiBC,MAAkC;AACjE,SAAO,OAAOA,SAAS,YAAaA,KAAaC;AACnD;AAFgBF;","names":["toReq","arg","body","query","realParam","method","url","Object","keys","length","entries","map","k","v","join","params","merge","args","ret","i","name","createReq","instance","config","console","warn","push","createMergeReq","key","post","isError","data","error"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/client/index.ts
|
|
5
|
+
function toReq(arg) {
|
|
6
|
+
const { body, query, realParam, method, url } = arg;
|
|
7
|
+
return {
|
|
8
|
+
method,
|
|
9
|
+
url,
|
|
10
|
+
body,
|
|
11
|
+
query: Object.keys(query).length > 0 ? `?${Object.entries(query).map(([k, v]) => `${k}=${v}`).join("&")}` : "",
|
|
12
|
+
params: realParam
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
__name(toReq, "toReq");
|
|
16
|
+
var merge = /* @__PURE__ */ __name((...args) => {
|
|
17
|
+
const ret = {};
|
|
18
|
+
for (const i of args) {
|
|
19
|
+
const { name, body, query, params } = i;
|
|
20
|
+
ret[name] = {
|
|
21
|
+
body,
|
|
22
|
+
query,
|
|
23
|
+
params
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return ret;
|
|
27
|
+
}, "merge");
|
|
28
|
+
function createReq(instance) {
|
|
29
|
+
return (arg, config) => {
|
|
30
|
+
const { url, params, query, body, method } = toReq(arg);
|
|
31
|
+
if (!method) {
|
|
32
|
+
console.warn("methods without route decorator won't send request");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const ret = [
|
|
36
|
+
`${url}${params}${query}`
|
|
37
|
+
];
|
|
38
|
+
body && ret.push(body);
|
|
39
|
+
config && ret.push(config);
|
|
40
|
+
return instance[method](...ret);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
__name(createReq, "createReq");
|
|
44
|
+
function createMergeReq(instance, key = "/__PHECDA_SERVER__") {
|
|
45
|
+
return (args, config) => {
|
|
46
|
+
return instance.post(key, merge(...args), config);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
__name(createMergeReq, "createMergeReq");
|
|
50
|
+
function isError(data) {
|
|
51
|
+
return typeof data === "object" && data.error;
|
|
52
|
+
}
|
|
53
|
+
__name(isError, "isError");
|
|
54
|
+
export {
|
|
55
|
+
createMergeReq,
|
|
56
|
+
createReq,
|
|
57
|
+
isError,
|
|
58
|
+
merge,
|
|
59
|
+
toReq
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport type { PError, RequestType, ResOrErr } from '../types'\ninterface RequestArgs {\n body: Record<string, any>\n query: Record<string, string>\n params: Record<string, string>\n realParam: string\n method: RequestType\n url: string\n name: string\n}\ntype MergedReqArg = Pick<RequestArgs, 'body' | 'query' | 'params'>\nexport function toReq(arg: RequestArgs) {\n const { body, query, realParam, method, url } = arg\n return { method, url, body, query: Object.keys(query).length > 0 ? `?${Object.entries(query).map(([k, v]) => `${k}=${v}`).join('&')}` : '', params: realParam }\n}\n\nexport const merge = (...args: RequestArgs[]) => {\n const ret = {} as Record<string, MergedReqArg>\n for (const i of args) {\n const { name, body, query, params } = i\n ret[name] = { body, query, params }\n }\n\n return ret\n}\n\nexport type RequestMethod = <F extends (...args: any[]) => any >(fn: F, args: Parameters<F>) => Promise<ReturnType<F>>\n\nexport function createReq(instance: AxiosInstance): <R>(arg: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<Awaited<R>> > {\n // @ts-expect-error methods without route decorator won't send request\n return (arg: any, config?: AxiosRequestConfig) => {\n const { url, params, query, body, method } = toReq(arg as RequestArgs)\n if (!method) {\n console.warn('methods without route decorator won\\'t send request')\n return\n }\n\n const ret = [`${url}${params}${query}`] as any[]\n body && ret.push(body)\n config && ret.push(config)\n // @ts-expect-error misdirction\n return instance[method](...ret)\n }\n}\n\nexport function createMergeReq(instance: AxiosInstance, key = '/__PHECDA_SERVER__'): < R extends unknown[]>(args: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<ResOrErr<R>>> {\n // @ts-expect-error misdirction\n return (args: RequestArgs[], config?: AxiosRequestConfig) => {\n return instance.post(key, merge(...args), config)\n }\n}\n\nexport function isError<T = any>(data: T | PError): data is PError {\n return typeof data === 'object' && (data as any).error\n}\n"],"mappings":";;;;AAYO,SAASA,MAAMC,KAAkB;AACtC,QAAM,EAAEC,MAAMC,OAAOC,WAAWC,QAAQC,IAAG,IAAKL;AAChD,SAAO;IAAEI;IAAQC;IAAKJ;IAAMC,OAAOI,OAAOC,KAAKL,KAAAA,EAAOM,SAAS,IAAI,IAAIF,OAAOG,QAAQP,KAAAA,EAAOQ,IAAI,CAAC,CAACC,GAAGC,CAAAA,MAAO,GAAGD,KAAKC,GAAG,EAAEC,KAAK,GAAA,MAAS;IAAIC,QAAQX;EAAU;AAChK;AAHgBJ;AAKT,IAAMgB,QAAQ,2BAAIC,SAAwB;AAC/C,QAAMC,MAAM,CAAC;AACb,aAAWC,KAAKF,MAAM;AACpB,UAAM,EAAEG,MAAMlB,MAAMC,OAAOY,OAAM,IAAKI;AACtCD,QAAIE,QAAQ;MAAElB;MAAMC;MAAOY;IAAO;EACpC;AAEA,SAAOG;AACT,GARqB;AAYd,SAASG,UAAUC,UAA0G;AAElI,SAAO,CAACrB,KAAUsB,WAAgC;AAChD,UAAM,EAAEjB,KAAKS,QAAQZ,OAAOD,MAAMG,OAAM,IAAKL,MAAMC,GAAAA;AACnD,QAAI,CAACI,QAAQ;AACXmB,cAAQC,KAAK,oDAAA;AACb;IACF;AAEA,UAAMP,MAAM;MAAC,GAAGZ,MAAMS,SAASZ;;AAC/BD,YAAQgB,IAAIQ,KAAKxB,IAAAA;AACjBqB,cAAUL,IAAIQ,KAAKH,MAAAA;AAEnB,WAAOD,SAASjB,QAAO,GAAIa,GAAAA;EAC7B;AACF;AAfgBG;AAiBT,SAASM,eAAeL,UAAyBM,MAAM,sBAA2H;AAEvL,SAAO,CAACX,MAAqBM,WAAgC;AAC3D,WAAOD,SAASO,KAAKD,KAAKZ,MAAAA,GAASC,IAAAA,GAAOM,MAAAA;EAC5C;AACF;AALgBI;AAOT,SAASG,QAAiBC,MAAkC;AACjE,SAAO,OAAOA,SAAS,YAAaA,KAAaC;AACnD;AAFgBF;","names":["toReq","arg","body","query","realParam","method","url","Object","keys","length","entries","map","k","v","join","params","merge","args","ret","i","name","createReq","instance","config","console","warn","push","createMergeReq","key","post","isError","data","error"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { S as ServerMeta, R as RequestType, C as Construct } from './types-6e2842b3.js';
|
|
2
|
+
export { M as MergeType, P as PError, a as ResOrErr, T as Transform, U as UnWrap } from './types-6e2842b3.js';
|
|
3
|
+
import { Express } from 'express';
|
|
4
|
+
import { PluginOption } from 'vite';
|
|
5
|
+
|
|
6
|
+
declare class Pmeta {
|
|
7
|
+
data: ServerMeta;
|
|
8
|
+
reflect: any[];
|
|
9
|
+
constructor(data: ServerMeta, reflect: any[]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface Ppipe {
|
|
13
|
+
transform(args: {
|
|
14
|
+
arg: any;
|
|
15
|
+
validate?: boolean;
|
|
16
|
+
}[], reflect: any[]): Promise<any[]>;
|
|
17
|
+
}
|
|
18
|
+
declare const defaultPipe: Ppipe;
|
|
19
|
+
|
|
20
|
+
declare class Pserver {
|
|
21
|
+
key: string;
|
|
22
|
+
meta: Pmeta;
|
|
23
|
+
method: string;
|
|
24
|
+
params: string[];
|
|
25
|
+
static pipe: Ppipe;
|
|
26
|
+
static guardsRecord: Record<string, (...params: any) => boolean>;
|
|
27
|
+
static middlewareRecord: Record<string, (...params: any) => boolean>;
|
|
28
|
+
static interceptorsRecord: Record<string, (...params: any) => any | ((...params: any) => any)>;
|
|
29
|
+
static serverRecord: Record<string, Pserver>;
|
|
30
|
+
constructor(key: string, meta: Pmeta);
|
|
31
|
+
static registerGuard(key: string, handler: any): void;
|
|
32
|
+
static registerInterceptor(key: string, handler: any): void;
|
|
33
|
+
useGuard(req: any, guards: string[]): Promise<void>;
|
|
34
|
+
useInterceptor(req: any, interceptors: string[]): Promise<any[]>;
|
|
35
|
+
usePost(ret: any, cbs: ((...params: any[]) => any)[]): Promise<any>;
|
|
36
|
+
usePipe(args: {
|
|
37
|
+
arg: any;
|
|
38
|
+
validate?: boolean;
|
|
39
|
+
}[], reflect: any[]): Promise<any[]>;
|
|
40
|
+
methodToHandler(method: (...params: any[]) => any): (req: any) => Promise<any>;
|
|
41
|
+
}
|
|
42
|
+
declare function addGuard(key: string, handler: (...params: any) => boolean): void;
|
|
43
|
+
declare function addInterceptor(key: string, handler: (...params: any) => any | ((...params: any) => any)): void;
|
|
44
|
+
declare function usePipe(pipe: Ppipe): void;
|
|
45
|
+
|
|
46
|
+
declare class Pcompiler {
|
|
47
|
+
content: string;
|
|
48
|
+
classMap: Record<string, {
|
|
49
|
+
[key: string]: string;
|
|
50
|
+
}>;
|
|
51
|
+
constructor();
|
|
52
|
+
getContent(): string;
|
|
53
|
+
addMethod(className: string, methodName: string, route?: string, requestType?: RequestType | '', params?: {
|
|
54
|
+
type: string;
|
|
55
|
+
key: string;
|
|
56
|
+
index: number;
|
|
57
|
+
}[]): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare function bindApp(app: Express, { meta, moduleMap }: {
|
|
61
|
+
meta: Pmeta[];
|
|
62
|
+
moduleMap: any;
|
|
63
|
+
}, key?: string): void;
|
|
64
|
+
|
|
65
|
+
declare function Factory<T>(Modules: Construct<T>[]): {
|
|
66
|
+
moduleMap: Map<string, any>;
|
|
67
|
+
meta: Pmeta[];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
declare function BaseParam(type: string, key: string, validate?: boolean): any;
|
|
71
|
+
declare function Body(key: string, validate?: boolean): any;
|
|
72
|
+
declare function Query(key: string, validate?: boolean): any;
|
|
73
|
+
declare function Param(key: string, validate?: boolean): any;
|
|
74
|
+
|
|
75
|
+
declare function Route(route: string, type?: string): any;
|
|
76
|
+
declare function Get(route: string): any;
|
|
77
|
+
declare function Post(route: string): any;
|
|
78
|
+
declare function Put(route: string): any;
|
|
79
|
+
declare function Delete(route: string): any;
|
|
80
|
+
declare function Controller(route: string): any;
|
|
81
|
+
|
|
82
|
+
declare function Inject(): void;
|
|
83
|
+
declare function Header(name: string, value: string): (target: any, k: PropertyKey) => void;
|
|
84
|
+
|
|
85
|
+
declare function Server(localPath: string): PluginOption;
|
|
86
|
+
|
|
87
|
+
declare class HttpException extends Error {
|
|
88
|
+
message: string;
|
|
89
|
+
status: number;
|
|
90
|
+
description: string;
|
|
91
|
+
constructor(message: string, status: number, description?: string);
|
|
92
|
+
get data(): {
|
|
93
|
+
message: string;
|
|
94
|
+
description: string;
|
|
95
|
+
status: number;
|
|
96
|
+
error: boolean;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class UndefinedException extends HttpException {
|
|
101
|
+
constructor(message: string);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare class ValidateException extends HttpException {
|
|
105
|
+
constructor(message: string);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class ForbiddenException extends HttpException {
|
|
109
|
+
constructor(message: string);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare class BadRequestException extends HttpException {
|
|
113
|
+
constructor(message: string);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { BadRequestException, BaseParam, Body, Construct, Controller, Delete, Factory, ForbiddenException, Get, Header, HttpException, Inject, Param, Pcompiler, Pmeta, Post, Ppipe, Pserver, Put, Query, RequestType, Route, Server, ServerMeta, UndefinedException, ValidateException, addGuard, addInterceptor, bindApp, defaultPipe, usePipe };
|