phecda-server 6.0.1 → 6.0.2
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/{chunk-TZYATAJX.js → chunk-7SYPUIBY.js} +2 -5
- package/dist/{chunk-YUXERDQ6.mjs → chunk-WXFZZZRY.mjs} +8 -11
- package/dist/{core-Blq8frmr.d.ts → core-2SNw8m2B.d.mts} +1 -1
- package/dist/{core-D2oL8Ge0.d.mts → core-BmJJLUqj.d.ts} +1 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +24 -24
- package/dist/index.mjs +8 -8
- package/dist/{types-BlIBlnVT.d.mts → meta-KtfiBIde.d.mts} +44 -44
- package/dist/{types-BlIBlnVT.d.ts → meta-KtfiBIde.d.ts} +44 -44
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +6 -6
- package/dist/rpc/bullmq/index.mjs +1 -1
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +5 -5
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +5 -5
- package/dist/rpc/nats/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +6 -6
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +6 -6
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/server/elysia/index.d.mts +3 -3
- package/dist/server/elysia/index.d.ts +3 -3
- package/dist/server/elysia/index.js +27 -15
- package/dist/server/elysia/index.mjs +15 -3
- package/dist/server/express/index.d.mts +3 -3
- package/dist/server/express/index.d.ts +3 -3
- package/dist/server/express/index.js +20 -16
- package/dist/server/express/index.mjs +7 -3
- package/dist/server/fastify/index.d.mts +3 -3
- package/dist/server/fastify/index.d.ts +3 -3
- package/dist/server/fastify/index.js +19 -15
- package/dist/server/fastify/index.mjs +7 -3
- package/dist/server/h3/index.d.mts +3 -3
- package/dist/server/h3/index.d.ts +3 -3
- package/dist/server/h3/index.js +18 -14
- package/dist/server/h3/index.mjs +7 -3
- package/dist/server/hono/index.d.mts +3 -3
- package/dist/server/hono/index.d.ts +3 -3
- package/dist/server/hono/index.js +19 -15
- package/dist/server/hono/index.mjs +7 -3
- package/dist/server/hyper-express/index.d.mts +3 -3
- package/dist/server/hyper-express/index.d.ts +3 -3
- package/dist/server/hyper-express/index.js +19 -15
- package/dist/server/hyper-express/index.mjs +7 -3
- package/dist/server/koa/index.d.mts +3 -3
- package/dist/server/koa/index.d.ts +3 -3
- package/dist/server/koa/index.js +20 -16
- package/dist/server/koa/index.mjs +7 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/{types-Dgxirc9f.d.mts → types-BvD3B5Ny.d.mts} +4 -2
- package/dist/{types-BCJhmpQh.d.ts → types-DIw7B6Up.d.ts} +4 -2
- package/dist/{types-B-ZFZajI.d.ts → types-JVT0mgLD.d.ts} +1 -1
- package/dist/{types-AgVwUXPC.d.mts → types-t9D1fU6G.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -15,14 +15,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/hyper-express");
|
|
|
15
15
|
function bind(router, data, opts = {}) {
|
|
16
16
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
17
17
|
const { moduleMap, meta } = data;
|
|
18
|
-
const metaMap =
|
|
18
|
+
const metaMap = _chunk7SYPUIBYjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
19
19
|
const { controller, http, func, tag } = meta2.data;
|
|
20
20
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
21
21
|
debug(`register method "${func}" in module "${tag}"`);
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
26
26
|
plugins: [
|
|
27
27
|
...globalPlugins,
|
|
28
28
|
...parallelPlugins
|
|
@@ -32,26 +32,26 @@ function bind(router, data, opts = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
registerRoute();
|
|
34
34
|
async function registerRoute() {
|
|
35
|
-
|
|
35
|
+
_chunk7SYPUIBYjs.Context.usePlugin(globalPlugins, "hyper-express").forEach((p) => router.use(p));
|
|
36
36
|
if (parallelRoute) {
|
|
37
37
|
router.post(parallelRoute, {
|
|
38
|
-
middlewares:
|
|
38
|
+
middlewares: _chunk7SYPUIBYjs.Context.usePlugin(parallelPlugins, "hyper-express")
|
|
39
39
|
}, async (req, res, next) => {
|
|
40
40
|
const body = await req.json();
|
|
41
41
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
42
|
+
const error = await _chunk7SYPUIBYjs.Context.filterRecord.default(e);
|
|
43
43
|
return res.status(error.status).json(error);
|
|
44
44
|
}
|
|
45
45
|
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
46
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
46
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.BadRequestException)("data format should be an array"));
|
|
47
47
|
try {
|
|
48
48
|
return Promise.all(body.map((item, i) => {
|
|
49
49
|
return new Promise(async (resolve) => {
|
|
50
50
|
const { tag, func } = item;
|
|
51
51
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
52
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
52
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
53
53
|
const meta2 = metaMap.get(tag)[func];
|
|
54
|
-
if (!meta2) return resolve(await
|
|
54
|
+
if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
55
55
|
const { data: { params } } = meta2;
|
|
56
56
|
const contextData = {
|
|
57
57
|
type: "hyper-express",
|
|
@@ -65,15 +65,17 @@ function bind(router, data, opts = {}) {
|
|
|
65
65
|
func,
|
|
66
66
|
next,
|
|
67
67
|
app: router,
|
|
68
|
-
...
|
|
68
|
+
..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, req.headers),
|
|
69
69
|
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => req.cookies[key], "getCookie"),
|
|
70
70
|
setCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key, value, opts2) => res.cookie(key, value, _optionalChain([opts2, 'optionalAccess', _2 => _2.expires]) && opts2.expires.getTime() - Date.now(), opts2 || {}), "setCookie"),
|
|
71
71
|
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
72
72
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
73
73
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
74
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
74
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
75
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => req, "getRequest"),
|
|
76
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => res, "getResponse")
|
|
75
77
|
};
|
|
76
|
-
const context = new (0,
|
|
78
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
77
79
|
context.run({
|
|
78
80
|
globalGuards,
|
|
79
81
|
globalInterceptors,
|
|
@@ -95,7 +97,7 @@ function bind(router, data, opts = {}) {
|
|
|
95
97
|
const { data: { params, plugins, http } } = meta2;
|
|
96
98
|
if (!_optionalChain([http, 'optionalAccess', _3 => _3.type])) continue;
|
|
97
99
|
const needBody = params.some((item) => item.type === "body");
|
|
98
|
-
router[http.type](http.prefix + http.route, ...
|
|
100
|
+
router[http.type](http.prefix + http.route, ..._chunk7SYPUIBYjs.Context.usePlugin(plugins, "hyper-express"), async (req, res, next) => {
|
|
99
101
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
100
102
|
const contextData = {
|
|
101
103
|
type: "hyper-express",
|
|
@@ -116,9 +118,11 @@ function bind(router, data, opts = {}) {
|
|
|
116
118
|
delCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => res.clearCookie(key), "delCookie"),
|
|
117
119
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => res.redirect(url), "redirect"),
|
|
118
120
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => res.set(headers), "setResHeaders"),
|
|
119
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus")
|
|
121
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (code) => res.status(code), "setResStatus"),
|
|
122
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => req, "getRequest"),
|
|
123
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => res, "getResponse")
|
|
120
124
|
};
|
|
121
|
-
const context = new (0,
|
|
125
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
122
126
|
if (http.headers) {
|
|
123
127
|
for (const name in http.headers) res.set(name, http.headers[name]);
|
|
124
128
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
argToReq,
|
|
5
5
|
createControllerMetaMap,
|
|
6
6
|
detectAopDep
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-WXFZZZRY.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-UXD62LGG.mjs";
|
|
@@ -71,7 +71,9 @@ function bind(router, data, opts = {}) {
|
|
|
71
71
|
delCookie: /* @__PURE__ */ __name((key) => res.clearCookie(key), "delCookie"),
|
|
72
72
|
redirect: /* @__PURE__ */ __name((url) => res.redirect(url), "redirect"),
|
|
73
73
|
setResHeaders: /* @__PURE__ */ __name((headers) => res.set(headers), "setResHeaders"),
|
|
74
|
-
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
|
|
74
|
+
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus"),
|
|
75
|
+
getRequest: /* @__PURE__ */ __name(() => req, "getRequest"),
|
|
76
|
+
getResponse: /* @__PURE__ */ __name(() => res, "getResponse")
|
|
75
77
|
};
|
|
76
78
|
const context = new Context(contextData);
|
|
77
79
|
context.run({
|
|
@@ -116,7 +118,9 @@ function bind(router, data, opts = {}) {
|
|
|
116
118
|
delCookie: /* @__PURE__ */ __name((key) => res.clearCookie(key), "delCookie"),
|
|
117
119
|
redirect: /* @__PURE__ */ __name((url) => res.redirect(url), "redirect"),
|
|
118
120
|
setResHeaders: /* @__PURE__ */ __name((headers) => res.set(headers), "setResHeaders"),
|
|
119
|
-
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus")
|
|
121
|
+
setResStatus: /* @__PURE__ */ __name((code) => res.status(code), "setResStatus"),
|
|
122
|
+
getRequest: /* @__PURE__ */ __name(() => req, "getRequest"),
|
|
123
|
+
getResponse: /* @__PURE__ */ __name(() => res, "getResponse")
|
|
120
124
|
};
|
|
121
125
|
const context = new Context(contextData);
|
|
122
126
|
if (http.headers) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-BvD3B5Ny.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-2SNw8m2B.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../
|
|
6
|
+
import '../../meta-KtfiBIde.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface KoaCtx extends HttpContext {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Router, { RouterParamContext } from '@koa/router';
|
|
2
2
|
import { DefaultContext, DefaultState } from 'koa';
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-DIw7B6Up.js';
|
|
4
|
+
import { F as Factory } from '../../core-BmJJLUqj.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../
|
|
6
|
+
import '../../meta-KtfiBIde.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface KoaCtx extends HttpContext {
|
package/dist/server/koa/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk7SYPUIBYjs = require('../../chunk-7SYPUIBY.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkGHFSIZUOjs = require('../../chunk-GHFSIZUO.js');
|
|
@@ -17,14 +17,14 @@ function bind(router, data, opts = {}) {
|
|
|
17
17
|
const { globalGuards, globalInterceptors, parallelRoute = "/__PHECDA_SERVER__", globalPlugins = [], parallelPlugins = [], globalFilter, globalPipe } = opts;
|
|
18
18
|
const { moduleMap, meta } = data;
|
|
19
19
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
20
|
-
const metaMap =
|
|
20
|
+
const metaMap = _chunk7SYPUIBYjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
21
|
const { controller, http, func, tag } = meta2.data;
|
|
22
22
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
23
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunk7SYPUIBYjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
plugins: [
|
|
29
29
|
...globalPlugins,
|
|
30
30
|
...parallelPlugins
|
|
@@ -34,25 +34,25 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
async function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunk7SYPUIBYjs.Context.usePlugin(globalPlugins, "koa").forEach((p) => router.use(p));
|
|
38
38
|
if (parallelRoute) {
|
|
39
|
-
router.post(parallelRoute, ...
|
|
39
|
+
router.post(parallelRoute, ..._chunk7SYPUIBYjs.Context.usePlugin(parallelPlugins, "koa"), async (ctx, next) => {
|
|
40
40
|
const { body } = ctx.request;
|
|
41
41
|
async function errorHandler(e) {
|
|
42
|
-
const error = await
|
|
42
|
+
const error = await _chunk7SYPUIBYjs.Context.filterRecord.default(e);
|
|
43
43
|
ctx.status = error.status;
|
|
44
44
|
ctx.body = error;
|
|
45
45
|
}
|
|
46
46
|
_chunkGHFSIZUOjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
47
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
47
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunk7SYPUIBYjs.BadRequestException)("data format should be an array"));
|
|
48
48
|
try {
|
|
49
49
|
return Promise.all(body.map((item, i) => {
|
|
50
50
|
return new Promise(async (resolve) => {
|
|
51
51
|
const { tag, func } = item;
|
|
52
52
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
53
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
53
|
+
if (!metaMap.has(tag)) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
54
54
|
const meta2 = metaMap.get(tag)[func];
|
|
55
|
-
if (!meta2) return resolve(await
|
|
55
|
+
if (!meta2) return resolve(await _chunk7SYPUIBYjs.Context.filterRecord.default(new (0, _chunk7SYPUIBYjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
56
56
|
const { data: { params } } = meta2;
|
|
57
57
|
const contextData = {
|
|
58
58
|
type: "koa",
|
|
@@ -63,7 +63,7 @@ function bind(router, data, opts = {}) {
|
|
|
63
63
|
parallel: true,
|
|
64
64
|
next,
|
|
65
65
|
app: router,
|
|
66
|
-
...
|
|
66
|
+
..._chunk7SYPUIBYjs.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
67
67
|
tag,
|
|
68
68
|
func,
|
|
69
69
|
getCookie: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
@@ -73,9 +73,11 @@ function bind(router, data, opts = {}) {
|
|
|
73
73
|
}), "delCookie"),
|
|
74
74
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
75
75
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
76
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus")
|
|
76
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
77
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
78
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
77
79
|
};
|
|
78
|
-
const context = new (0,
|
|
80
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
79
81
|
context.run({
|
|
80
82
|
globalGuards,
|
|
81
83
|
globalInterceptors,
|
|
@@ -96,7 +98,7 @@ function bind(router, data, opts = {}) {
|
|
|
96
98
|
const meta2 = metaMap.get(tag)[func];
|
|
97
99
|
const { data: { plugins, http } } = meta2;
|
|
98
100
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
99
|
-
router[http.type](http.prefix + http.route, ...
|
|
101
|
+
router[http.type](http.prefix + http.route, ..._chunk7SYPUIBYjs.Context.usePlugin(plugins, "koa"), async (ctx, next) => {
|
|
100
102
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
101
103
|
const contextData = {
|
|
102
104
|
type: "koa",
|
|
@@ -118,9 +120,11 @@ function bind(router, data, opts = {}) {
|
|
|
118
120
|
}), "delCookie"),
|
|
119
121
|
redirect: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
120
122
|
setResHeaders: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
121
|
-
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus")
|
|
123
|
+
setResStatus: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
124
|
+
getRequest: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
125
|
+
getResponse: /* @__PURE__ */ _chunkGHFSIZUOjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
122
126
|
};
|
|
123
|
-
const context = new (0,
|
|
127
|
+
const context = new (0, _chunk7SYPUIBYjs.Context)(contextData);
|
|
124
128
|
if (http.headers) ctx.set(http.headers);
|
|
125
129
|
await context.run({
|
|
126
130
|
globalGuards,
|
|
@@ -140,7 +144,7 @@ function bind(router, data, opts = {}) {
|
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
146
|
_chunkGHFSIZUOjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
143
|
-
|
|
147
|
+
_chunk7SYPUIBYjs.HMR.call(void 0, async () => {
|
|
144
148
|
router.stack = originStack;
|
|
145
149
|
registerRoute();
|
|
146
150
|
});
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-WXFZZZRY.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
11
|
} from "../../chunk-UXD62LGG.mjs";
|
|
@@ -73,7 +73,9 @@ function bind(router, data, opts = {}) {
|
|
|
73
73
|
}), "delCookie"),
|
|
74
74
|
redirect: /* @__PURE__ */ __name((url) => ctx.redirect(url), "redirect"),
|
|
75
75
|
setResHeaders: /* @__PURE__ */ __name((headers) => ctx.set(headers), "setResHeaders"),
|
|
76
|
-
setResStatus: /* @__PURE__ */ __name((status) => ctx.status = status, "setResStatus")
|
|
76
|
+
setResStatus: /* @__PURE__ */ __name((status) => ctx.status = status, "setResStatus"),
|
|
77
|
+
getRequest: /* @__PURE__ */ __name(() => ctx.req, "getRequest"),
|
|
78
|
+
getResponse: /* @__PURE__ */ __name(() => ctx.res, "getResponse")
|
|
77
79
|
};
|
|
78
80
|
const context = new Context(contextData);
|
|
79
81
|
context.run({
|
|
@@ -118,7 +120,9 @@ function bind(router, data, opts = {}) {
|
|
|
118
120
|
}), "delCookie"),
|
|
119
121
|
redirect: /* @__PURE__ */ __name((url) => ctx.redirect(url), "redirect"),
|
|
120
122
|
setResHeaders: /* @__PURE__ */ __name((headers) => ctx.set(headers), "setResHeaders"),
|
|
121
|
-
setResStatus: /* @__PURE__ */ __name((status) => ctx.status = status, "setResStatus")
|
|
123
|
+
setResStatus: /* @__PURE__ */ __name((status) => ctx.status = status, "setResStatus"),
|
|
124
|
+
getRequest: /* @__PURE__ */ __name(() => ctx.req, "getRequest"),
|
|
125
|
+
getResponse: /* @__PURE__ */ __name(() => ctx.res, "getResponse")
|
|
122
126
|
};
|
|
123
127
|
const context = new Context(contextData);
|
|
124
128
|
if (http.headers) ctx.set(http.headers);
|
package/dist/test.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory } from './core-
|
|
6
|
-
import { P as PickFunc } from './
|
|
5
|
+
import { F as Factory } from './core-2SNw8m2B.mjs';
|
|
6
|
+
import { P as PickFunc } from './meta-KtfiBIde.mjs';
|
|
7
7
|
|
|
8
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
9
|
get<C extends T[number]>(Model: C): InstanceType<C>;
|
|
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
|
11
11
|
type SuperTestRequest<T> = {
|
|
12
12
|
[K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
|
|
13
13
|
};
|
|
14
|
-
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "
|
|
14
|
+
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "key" | "query" | "use" | "on" | "set" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "pfx" | "cert"> & {
|
|
15
15
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
16
|
}>;
|
|
17
17
|
|
package/dist/test.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory } from './core-
|
|
6
|
-
import { P as PickFunc } from './
|
|
5
|
+
import { F as Factory } from './core-BmJJLUqj.js';
|
|
6
|
+
import { P as PickFunc } from './meta-KtfiBIde.js';
|
|
7
7
|
|
|
8
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
9
|
get<C extends T[number]>(Model: C): InstanceType<C>;
|
|
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
|
11
11
|
type SuperTestRequest<T> = {
|
|
12
12
|
[K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
|
|
13
13
|
};
|
|
14
|
-
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "
|
|
14
|
+
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "key" | "query" | "use" | "on" | "set" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "pfx" | "cert"> & {
|
|
15
15
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
16
|
}>;
|
|
17
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IncomingHttpHeaders } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as BaseContext } from './
|
|
1
|
+
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { D as DefaultOptions, B as BaseContext } from './meta-KtfiBIde.mjs';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -28,6 +28,8 @@ interface HttpContext extends BaseContext {
|
|
|
28
28
|
delCookie(key: string): void;
|
|
29
29
|
setResHeaders: (headers: Record<string, string>) => void;
|
|
30
30
|
setResStatus: (status: number) => void;
|
|
31
|
+
getRequest: () => IncomingMessage;
|
|
32
|
+
getResponse: () => ServerResponse;
|
|
31
33
|
}
|
|
32
34
|
interface CookieSerializeOptions {
|
|
33
35
|
domain?: string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IncomingHttpHeaders } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as BaseContext } from './
|
|
1
|
+
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { D as DefaultOptions, B as BaseContext } from './meta-KtfiBIde.js';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -28,6 +28,8 @@ interface HttpContext extends BaseContext {
|
|
|
28
28
|
delCookie(key: string): void;
|
|
29
29
|
setResHeaders: (headers: Record<string, string>) => void;
|
|
30
30
|
setResStatus: (status: number) => void;
|
|
31
|
+
getRequest: () => IncomingMessage;
|
|
32
|
+
getResponse: () => ServerResponse;
|
|
31
33
|
}
|
|
32
34
|
interface CookieSerializeOptions {
|
|
33
35
|
domain?: string | undefined;
|