phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.9
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/bin/cli.mjs +10 -1
- package/dist/{chunk-M5HGFUCV.js → chunk-5RBTN33A.js} +23 -3
- package/dist/{chunk-RGSKKTHD.mjs → chunk-7ZGYJ5OW.mjs} +88 -54
- package/dist/{chunk-IRXNF6ZE.mjs → chunk-CVPZWDXU.mjs} +39 -30
- package/dist/{chunk-MENRZSGW.js → chunk-FX3LDQII.js} +88 -79
- package/dist/{chunk-C5BVKEGW.mjs → chunk-FXTJ3BJ6.mjs} +25 -5
- package/dist/{chunk-XSMUJ77A.js → chunk-KJUD2BKE.js} +103 -69
- package/dist/{chunk-JPSXNDXP.mjs → chunk-ODVWOXVB.mjs} +1 -1
- package/dist/{chunk-VYMSCWXC.js → chunk-V5EYXVJT.js} +24 -24
- package/dist/{core-DU7gQKSk.d.mts → core-BDkhrEyf.d.mts} +4 -3
- package/dist/{core-CzElxZoF.d.ts → core-D_cz0tKa.d.ts} +4 -3
- package/dist/helper.d.mts +7 -5
- package/dist/helper.d.ts +7 -5
- package/dist/helper.js +8 -3
- package/dist/helper.mjs +10 -5
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +41 -44
- package/dist/http/elysia/index.mjs +7 -10
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +38 -41
- package/dist/http/express/index.mjs +7 -10
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +39 -42
- package/dist/http/fastify/index.mjs +7 -10
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +39 -42
- package/dist/http/h3/index.mjs +7 -10
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +35 -39
- package/dist/http/hono/index.mjs +3 -7
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +36 -39
- package/dist/http/hyper-express/index.mjs +6 -9
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +38 -41
- package/dist/http/koa/index.mjs +7 -10
- package/dist/index.d.mts +35 -33
- package/dist/index.d.ts +35 -33
- package/dist/index.js +42 -43
- package/dist/index.mjs +15 -16
- package/dist/{meta-BTnLXuCa.d.ts → meta-BX5jhe4Z.d.mts} +3 -4
- package/dist/{meta-BTnLXuCa.d.mts → meta-BX5jhe4Z.d.ts} +3 -4
- package/dist/rpc/bullmq/index.d.mts +4 -4
- package/dist/rpc/bullmq/index.d.ts +4 -4
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +3 -3
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +3 -3
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +3 -3
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +3 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-CbfaGkPA.d.ts → types-B-rUM9Fm.d.mts} +3 -3
- package/dist/{types--E-OCZhC.d.ts → types-CMeuFoyd.d.ts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-DKVhyZk_.d.mts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-MxxtkZXw.d.ts} +3 -3
- package/package.json +3 -2
- package/register/index.mjs +20 -11
- package/register/loader.mjs +13 -28
package/dist/http/koa/index.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
var _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
|
|
7
8
|
|
|
8
|
-
var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.js');
|
|
12
12
|
|
|
13
13
|
// src/http/koa/bind.ts
|
|
14
14
|
var _router = require('@koa/router'); var _router2 = _interopRequireDefault(_router);
|
|
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
|
|
|
18
18
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
19
|
const { moduleMap, meta } = data;
|
|
20
20
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkFX3LDQIIjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, func, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
24
24
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkFX3LDQIIjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -34,29 +34,28 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunkFX3LDQIIjs.Context.applyAddons(globalAddons, router, "koa");
|
|
38
38
|
if (parallelRoute) {
|
|
39
39
|
const subRouter = new (0, _router2.default)();
|
|
40
|
-
|
|
40
|
+
_chunkFX3LDQIIjs.Context.applyAddons(parallelAddons, subRouter, "koa");
|
|
41
41
|
subRouter.post(parallelRoute, async (ctx, next) => {
|
|
42
42
|
const { body } = ctx.request;
|
|
43
43
|
async function errorHandler(e) {
|
|
44
|
-
const error = await
|
|
44
|
+
const error = await _chunkFX3LDQIIjs.Context.filterRecord.default(e);
|
|
45
45
|
ctx.status = error.status;
|
|
46
46
|
ctx.body = error;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
48
|
+
_chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
|
|
49
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.BadRequestException)("data format should be an array"));
|
|
50
50
|
try {
|
|
51
51
|
return Promise.all(body.map((item, i) => {
|
|
52
52
|
return new Promise(async (resolve) => {
|
|
53
53
|
const { tag, func } = item;
|
|
54
54
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
55
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
55
|
+
if (!metaMap.has(tag)) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
|
-
if (!meta2) return resolve(await
|
|
58
|
-
const
|
|
59
|
-
const aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
|
|
57
|
+
if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
58
|
+
const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
60
59
|
globalGuards,
|
|
61
60
|
globalFilter,
|
|
62
61
|
globalPipe
|
|
@@ -71,21 +70,19 @@ function bind(router, data, opts = {}) {
|
|
|
71
70
|
parallel: true,
|
|
72
71
|
next,
|
|
73
72
|
app: router,
|
|
74
|
-
...
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
79
|
-
delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
73
|
+
...item,
|
|
74
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
75
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
76
|
+
delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
80
77
|
expires: /* @__PURE__ */ new Date(0)
|
|
81
78
|
}), "delCookie"),
|
|
82
|
-
redirect: /* @__PURE__ */
|
|
83
|
-
setResHeaders: /* @__PURE__ */
|
|
84
|
-
setResStatus: /* @__PURE__ */
|
|
85
|
-
getRequest: /* @__PURE__ */
|
|
86
|
-
getResponse: /* @__PURE__ */
|
|
79
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
80
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
81
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
82
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
83
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
87
84
|
};
|
|
88
|
-
const context = new (0,
|
|
85
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
89
86
|
context.run(aop, resolve, resolve);
|
|
90
87
|
});
|
|
91
88
|
})).then((ret) => {
|
|
@@ -104,15 +101,15 @@ function bind(router, data, opts = {}) {
|
|
|
104
101
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
105
102
|
let aop;
|
|
106
103
|
if (!dynamic) {
|
|
107
|
-
aop =
|
|
104
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
108
105
|
globalFilter,
|
|
109
106
|
globalGuards,
|
|
110
107
|
globalPipe
|
|
111
108
|
});
|
|
112
109
|
}
|
|
113
110
|
const subRouter = new (0, _router2.default)();
|
|
114
|
-
|
|
115
|
-
router[http.type](http.prefix
|
|
111
|
+
_chunkFX3LDQIIjs.Context.applyAddons(addons, subRouter, "koa");
|
|
112
|
+
router[http.type](_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
|
|
116
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
117
114
|
const contextData = {
|
|
118
115
|
type: "koa",
|
|
@@ -128,21 +125,21 @@ function bind(router, data, opts = {}) {
|
|
|
128
125
|
body: ctx.request.body,
|
|
129
126
|
headers: ctx.headers,
|
|
130
127
|
next,
|
|
131
|
-
getCookie: /* @__PURE__ */
|
|
132
|
-
setCookie: /* @__PURE__ */
|
|
133
|
-
delCookie: /* @__PURE__ */
|
|
128
|
+
getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
129
|
+
setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
130
|
+
delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
134
131
|
expires: /* @__PURE__ */ new Date(0)
|
|
135
132
|
}), "delCookie"),
|
|
136
|
-
redirect: /* @__PURE__ */
|
|
137
|
-
setResHeaders: /* @__PURE__ */
|
|
138
|
-
setResStatus: /* @__PURE__ */
|
|
139
|
-
getRequest: /* @__PURE__ */
|
|
140
|
-
getResponse: /* @__PURE__ */
|
|
133
|
+
redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
134
|
+
setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
135
|
+
setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
136
|
+
getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
137
|
+
getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
141
138
|
};
|
|
142
|
-
const context = new (0,
|
|
139
|
+
const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
|
|
143
140
|
if (http.headers) ctx.set(http.headers);
|
|
144
141
|
if (dynamic) {
|
|
145
|
-
aop =
|
|
142
|
+
aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
|
|
146
143
|
globalFilter,
|
|
147
144
|
globalGuards,
|
|
148
145
|
globalPipe
|
|
@@ -161,13 +158,13 @@ function bind(router, data, opts = {}) {
|
|
|
161
158
|
}
|
|
162
159
|
}
|
|
163
160
|
}
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
_chunk5RBTN33Ajs.__name.call(void 0, registerRoute, "registerRoute");
|
|
162
|
+
_chunk5RBTN33Ajs.HMR.call(void 0, async () => {
|
|
166
163
|
router.stack = originStack;
|
|
167
164
|
registerRoute();
|
|
168
165
|
});
|
|
169
166
|
}
|
|
170
|
-
|
|
167
|
+
_chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
|
|
171
168
|
|
|
172
169
|
|
|
173
170
|
exports.bind = bind;
|
package/dist/http/koa/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BadRequestException,
|
|
3
3
|
Context,
|
|
4
|
-
HMR,
|
|
5
|
-
argToReq,
|
|
6
4
|
createControllerMetaMap,
|
|
7
|
-
detectAopDep
|
|
8
|
-
|
|
5
|
+
detectAopDep,
|
|
6
|
+
joinUrl
|
|
7
|
+
} from "../../chunk-CVPZWDXU.mjs";
|
|
9
8
|
import {
|
|
9
|
+
HMR,
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-FXTJ3BJ6.mjs";
|
|
12
12
|
|
|
13
13
|
// src/http/koa/bind.ts
|
|
14
14
|
import Router from "@koa/router";
|
|
@@ -55,7 +55,6 @@ function bind(router, data, opts = {}) {
|
|
|
55
55
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
58
|
-
const { data: { params } } = meta2;
|
|
59
58
|
const aop = Context.getAop(meta2, {
|
|
60
59
|
globalGuards,
|
|
61
60
|
globalFilter,
|
|
@@ -71,9 +70,7 @@ function bind(router, data, opts = {}) {
|
|
|
71
70
|
parallel: true,
|
|
72
71
|
next,
|
|
73
72
|
app: router,
|
|
74
|
-
...
|
|
75
|
-
tag,
|
|
76
|
-
func,
|
|
73
|
+
...item,
|
|
77
74
|
getCookie: /* @__PURE__ */ __name((key) => ctx.cookies.get(key), "getCookie"),
|
|
78
75
|
setCookie: /* @__PURE__ */ __name((key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
79
76
|
delCookie: /* @__PURE__ */ __name((key) => ctx.cookies.set(key, "", {
|
|
@@ -112,7 +109,7 @@ function bind(router, data, opts = {}) {
|
|
|
112
109
|
}
|
|
113
110
|
const subRouter = new Router();
|
|
114
111
|
Context.applyAddons(addons, subRouter, "koa");
|
|
115
|
-
router[http.type](http.prefix
|
|
112
|
+
router[http.type](joinUrl(http.prefix, http.route), async (ctx, next) => {
|
|
116
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
117
114
|
const contextData = {
|
|
118
115
|
type: "koa",
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as
|
|
3
|
-
import { G as Generator } from './core-
|
|
4
|
-
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-
|
|
1
|
+
import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-BX5jhe4Z.mjs';
|
|
2
|
+
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-BX5jhe4Z.mjs';
|
|
3
|
+
import { G as Generator } from './core-BDkhrEyf.mjs';
|
|
4
|
+
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-BDkhrEyf.mjs';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types-
|
|
9
|
-
import { R as
|
|
10
|
-
export { b as RpcClientOptions, a as RpcServerOptions } from './types-
|
|
7
|
+
import { H as HttpCtx } from './types-DKVhyZk_.mjs';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-DKVhyZk_.mjs';
|
|
9
|
+
import { R as RpcCtx } from './types-B-rUM9Fm.mjs';
|
|
10
|
+
export { b as RpcClientOptions, a as RpcServerOptions } from './types-B-rUM9Fm.mjs';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
|
@@ -102,11 +102,11 @@ interface PipeArg {
|
|
|
102
102
|
reflect: any;
|
|
103
103
|
define: Record<string, any>;
|
|
104
104
|
}
|
|
105
|
-
type GuardType<
|
|
106
|
-
type PipeType<
|
|
107
|
-
type FilterType<
|
|
108
|
-
declare class Context<
|
|
109
|
-
data:
|
|
105
|
+
type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any;
|
|
106
|
+
type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>;
|
|
107
|
+
type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any;
|
|
108
|
+
declare class Context<Ctx extends BaseCtx> {
|
|
109
|
+
data: Ctx;
|
|
110
110
|
method: string;
|
|
111
111
|
params: string[];
|
|
112
112
|
static filterRecord: Record<PropertyKey, FilterType>;
|
|
@@ -119,7 +119,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
119
119
|
value: (router: any, framework: string) => any;
|
|
120
120
|
priority: number;
|
|
121
121
|
}>;
|
|
122
|
-
|
|
122
|
+
ctx: Ctx;
|
|
123
|
+
protected canGetCtx: boolean;
|
|
124
|
+
constructor(data: Ctx);
|
|
123
125
|
static getAop(meta: ControllerMeta, opts: DefaultOptions): {
|
|
124
126
|
guards: GuardType<any>[];
|
|
125
127
|
pipe: PipeType<any>[];
|
|
@@ -135,9 +137,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
135
137
|
static getGuards(guards: string[]): GuardType<any>[];
|
|
136
138
|
static applyAddons(addons: string[], router: any, framework: string): void;
|
|
137
139
|
}
|
|
138
|
-
declare function addPipe<C extends
|
|
139
|
-
declare function addFilter<C extends
|
|
140
|
-
declare function addGuard<C extends
|
|
140
|
+
declare function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>): void;
|
|
141
|
+
declare function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>): void;
|
|
142
|
+
declare function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
|
|
141
143
|
declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
|
|
142
144
|
|
|
143
145
|
declare class RPCGenerator extends Generator {
|
|
@@ -197,33 +199,33 @@ interface Logger {
|
|
|
197
199
|
declare function setLogger(logger: Logger): void;
|
|
198
200
|
declare function getLogger(): Logger;
|
|
199
201
|
declare function log(msg: unknown, level?: LogLevel, ctx?: any): void;
|
|
200
|
-
declare function runMiddleware(ctx:
|
|
202
|
+
declare function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
|
|
201
203
|
|
|
202
204
|
declare class ServerBase extends Base {
|
|
203
205
|
emitter: Emitter;
|
|
204
206
|
log(msg: unknown, level?: LogLevel): void;
|
|
205
207
|
}
|
|
206
|
-
declare class HttpBase extends ServerBase {
|
|
207
|
-
context:
|
|
208
|
+
declare class HttpBase<Ctx extends HttpCtx = HttpCtx> extends ServerBase {
|
|
209
|
+
context: Ctx;
|
|
208
210
|
}
|
|
209
|
-
declare class RpcBase extends ServerBase {
|
|
210
|
-
context:
|
|
211
|
+
declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
|
|
212
|
+
context: Ctx;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
|
-
declare abstract class PFilter<
|
|
215
|
+
declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
|
|
214
216
|
readonly key: PropertyKey;
|
|
215
217
|
constructor(tag?: string);
|
|
216
|
-
abstract use(error: Error | E, ctx?:
|
|
218
|
+
abstract use(error: Error | E, ctx?: Ctx): BaseError;
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
declare abstract class PGuard<
|
|
220
|
-
abstract use(ctx:
|
|
221
|
+
declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
|
|
222
|
+
abstract use(ctx: Ctx, next: () => Promise<any>): any;
|
|
221
223
|
readonly key: PropertyKey;
|
|
222
224
|
priority: number;
|
|
223
225
|
constructor(tag?: string);
|
|
224
226
|
}
|
|
225
227
|
|
|
226
|
-
declare abstract class PPipe<
|
|
228
|
+
declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
|
|
227
229
|
readonly key: PropertyKey;
|
|
228
230
|
constructor(tag?: string);
|
|
229
231
|
abstract use(param: {
|
|
@@ -233,7 +235,7 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
|
|
|
233
235
|
type: string;
|
|
234
236
|
index: number;
|
|
235
237
|
reflect: any;
|
|
236
|
-
}, ctx:
|
|
238
|
+
}, ctx: Ctx): any;
|
|
237
239
|
}
|
|
238
240
|
|
|
239
241
|
declare abstract class PAddon extends ServerBase {
|
|
@@ -243,8 +245,8 @@ declare abstract class PAddon extends ServerBase {
|
|
|
243
245
|
abstract use(router: any, framework: string): undefined;
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
interface PExtension<
|
|
247
|
-
guard(ctx:
|
|
248
|
+
interface PExtension<Ctx extends BaseCtx = any, E extends Exception = Exception> {
|
|
249
|
+
guard(ctx: Ctx): Promise<boolean> | boolean;
|
|
248
250
|
pipe(param: {
|
|
249
251
|
arg: any;
|
|
250
252
|
option?: any;
|
|
@@ -252,8 +254,8 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
|
|
|
252
254
|
type: string;
|
|
253
255
|
index: number;
|
|
254
256
|
reflect: any;
|
|
255
|
-
}, ctx:
|
|
256
|
-
filter(error: Error | E, ctx?:
|
|
257
|
+
}, ctx: Ctx): any;
|
|
258
|
+
filter(error: Error | E, ctx?: Ctx): BaseError;
|
|
257
259
|
addon<Addon = any>(framework: string): Addon;
|
|
258
260
|
}
|
|
259
261
|
declare class PExtension extends ServerBase {
|
|
@@ -263,4 +265,4 @@ declare class PExtension extends ServerBase {
|
|
|
263
265
|
constructor(tag?: string);
|
|
264
266
|
}
|
|
265
267
|
|
|
266
|
-
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException,
|
|
268
|
+
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseCtx, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpCtx, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcCtx, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as
|
|
3
|
-
import { G as Generator } from './core-
|
|
4
|
-
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-
|
|
1
|
+
import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-BX5jhe4Z.js';
|
|
2
|
+
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-BX5jhe4Z.js';
|
|
3
|
+
import { G as Generator } from './core-D_cz0tKa.js';
|
|
4
|
+
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-D_cz0tKa.js';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types
|
|
9
|
-
import { R as
|
|
10
|
-
export { b as RpcClientOptions, a as RpcServerOptions } from './types-
|
|
7
|
+
import { H as HttpCtx } from './types-CMeuFoyd.js';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-CMeuFoyd.js';
|
|
9
|
+
import { R as RpcCtx } from './types-MxxtkZXw.js';
|
|
10
|
+
export { b as RpcClientOptions, a as RpcServerOptions } from './types-MxxtkZXw.js';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
|
@@ -102,11 +102,11 @@ interface PipeArg {
|
|
|
102
102
|
reflect: any;
|
|
103
103
|
define: Record<string, any>;
|
|
104
104
|
}
|
|
105
|
-
type GuardType<
|
|
106
|
-
type PipeType<
|
|
107
|
-
type FilterType<
|
|
108
|
-
declare class Context<
|
|
109
|
-
data:
|
|
105
|
+
type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any;
|
|
106
|
+
type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>;
|
|
107
|
+
type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any;
|
|
108
|
+
declare class Context<Ctx extends BaseCtx> {
|
|
109
|
+
data: Ctx;
|
|
110
110
|
method: string;
|
|
111
111
|
params: string[];
|
|
112
112
|
static filterRecord: Record<PropertyKey, FilterType>;
|
|
@@ -119,7 +119,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
119
119
|
value: (router: any, framework: string) => any;
|
|
120
120
|
priority: number;
|
|
121
121
|
}>;
|
|
122
|
-
|
|
122
|
+
ctx: Ctx;
|
|
123
|
+
protected canGetCtx: boolean;
|
|
124
|
+
constructor(data: Ctx);
|
|
123
125
|
static getAop(meta: ControllerMeta, opts: DefaultOptions): {
|
|
124
126
|
guards: GuardType<any>[];
|
|
125
127
|
pipe: PipeType<any>[];
|
|
@@ -135,9 +137,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
135
137
|
static getGuards(guards: string[]): GuardType<any>[];
|
|
136
138
|
static applyAddons(addons: string[], router: any, framework: string): void;
|
|
137
139
|
}
|
|
138
|
-
declare function addPipe<C extends
|
|
139
|
-
declare function addFilter<C extends
|
|
140
|
-
declare function addGuard<C extends
|
|
140
|
+
declare function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>): void;
|
|
141
|
+
declare function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>): void;
|
|
142
|
+
declare function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
|
|
141
143
|
declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
|
|
142
144
|
|
|
143
145
|
declare class RPCGenerator extends Generator {
|
|
@@ -197,33 +199,33 @@ interface Logger {
|
|
|
197
199
|
declare function setLogger(logger: Logger): void;
|
|
198
200
|
declare function getLogger(): Logger;
|
|
199
201
|
declare function log(msg: unknown, level?: LogLevel, ctx?: any): void;
|
|
200
|
-
declare function runMiddleware(ctx:
|
|
202
|
+
declare function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
|
|
201
203
|
|
|
202
204
|
declare class ServerBase extends Base {
|
|
203
205
|
emitter: Emitter;
|
|
204
206
|
log(msg: unknown, level?: LogLevel): void;
|
|
205
207
|
}
|
|
206
|
-
declare class HttpBase extends ServerBase {
|
|
207
|
-
context:
|
|
208
|
+
declare class HttpBase<Ctx extends HttpCtx = HttpCtx> extends ServerBase {
|
|
209
|
+
context: Ctx;
|
|
208
210
|
}
|
|
209
|
-
declare class RpcBase extends ServerBase {
|
|
210
|
-
context:
|
|
211
|
+
declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
|
|
212
|
+
context: Ctx;
|
|
211
213
|
}
|
|
212
214
|
|
|
213
|
-
declare abstract class PFilter<
|
|
215
|
+
declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
|
|
214
216
|
readonly key: PropertyKey;
|
|
215
217
|
constructor(tag?: string);
|
|
216
|
-
abstract use(error: Error | E, ctx?:
|
|
218
|
+
abstract use(error: Error | E, ctx?: Ctx): BaseError;
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
declare abstract class PGuard<
|
|
220
|
-
abstract use(ctx:
|
|
221
|
+
declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
|
|
222
|
+
abstract use(ctx: Ctx, next: () => Promise<any>): any;
|
|
221
223
|
readonly key: PropertyKey;
|
|
222
224
|
priority: number;
|
|
223
225
|
constructor(tag?: string);
|
|
224
226
|
}
|
|
225
227
|
|
|
226
|
-
declare abstract class PPipe<
|
|
228
|
+
declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
|
|
227
229
|
readonly key: PropertyKey;
|
|
228
230
|
constructor(tag?: string);
|
|
229
231
|
abstract use(param: {
|
|
@@ -233,7 +235,7 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
|
|
|
233
235
|
type: string;
|
|
234
236
|
index: number;
|
|
235
237
|
reflect: any;
|
|
236
|
-
}, ctx:
|
|
238
|
+
}, ctx: Ctx): any;
|
|
237
239
|
}
|
|
238
240
|
|
|
239
241
|
declare abstract class PAddon extends ServerBase {
|
|
@@ -243,8 +245,8 @@ declare abstract class PAddon extends ServerBase {
|
|
|
243
245
|
abstract use(router: any, framework: string): undefined;
|
|
244
246
|
}
|
|
245
247
|
|
|
246
|
-
interface PExtension<
|
|
247
|
-
guard(ctx:
|
|
248
|
+
interface PExtension<Ctx extends BaseCtx = any, E extends Exception = Exception> {
|
|
249
|
+
guard(ctx: Ctx): Promise<boolean> | boolean;
|
|
248
250
|
pipe(param: {
|
|
249
251
|
arg: any;
|
|
250
252
|
option?: any;
|
|
@@ -252,8 +254,8 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
|
|
|
252
254
|
type: string;
|
|
253
255
|
index: number;
|
|
254
256
|
reflect: any;
|
|
255
|
-
}, ctx:
|
|
256
|
-
filter(error: Error | E, ctx?:
|
|
257
|
+
}, ctx: Ctx): any;
|
|
258
|
+
filter(error: Error | E, ctx?: Ctx): BaseError;
|
|
257
259
|
addon<Addon = any>(framework: string): Addon;
|
|
258
260
|
}
|
|
259
261
|
declare class PExtension extends ServerBase {
|
|
@@ -263,4 +265,4 @@ declare class PExtension extends ServerBase {
|
|
|
263
265
|
constructor(tag?: string);
|
|
264
266
|
}
|
|
265
267
|
|
|
266
|
-
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException,
|
|
268
|
+
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseCtx, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpCtx, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcCtx, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
|