phecda-server 5.0.0-alpha.12 → 5.0.0-alpha.13
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-L5SFPHG6.mjs → chunk-BADPI5WG.mjs} +5 -5
- package/dist/{chunk-27WMBKFH.js → chunk-INPMEA67.js} +16 -20
- package/dist/{chunk-KOWUK5OV.js → chunk-MFCPWVO5.js} +5 -5
- package/dist/{chunk-UXPHQ7OT.mjs → chunk-Y7AOZMC2.mjs} +14 -18
- package/dist/{core-295348b7.d.ts → core-11dd822c.d.ts} +6 -4
- package/dist/index.d.ts +19 -18
- package/dist/index.js +36 -23
- package/dist/index.mjs +16 -3
- package/dist/rpc/kafka/index.d.ts +1 -1
- package/dist/rpc/kafka/index.js +4 -4
- package/dist/rpc/kafka/index.mjs +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +1 -1
- package/dist/rpc/rabbitmq/index.js +4 -4
- package/dist/rpc/rabbitmq/index.mjs +1 -1
- package/dist/rpc/redis/index.d.ts +1 -1
- package/dist/rpc/redis/index.js +4 -4
- package/dist/rpc/redis/index.mjs +1 -1
- package/dist/server/express/index.d.ts +1 -1
- package/dist/server/express/index.js +10 -10
- package/dist/server/express/index.mjs +1 -1
- package/dist/server/fastify/index.d.ts +1 -1
- package/dist/server/fastify/index.js +11 -11
- package/dist/server/fastify/index.mjs +1 -1
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/h3/index.js +10 -10
- package/dist/server/h3/index.mjs +1 -1
- package/dist/server/koa/index.d.ts +1 -1
- package/dist/server/koa/index.js +10 -10
- package/dist/server/koa/index.mjs +1 -1
- package/dist/test.d.ts +5 -4
- package/dist/test.js +42 -40
- package/dist/test.mjs +41 -39
- package/package.json +2 -2
package/dist/test.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkINPMEA67js = require('./chunk-INPMEA67.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkGWLM5DEJjs = require('./chunk-GWLM5DEJ.js');
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
async function TestFactory(...Modules) {
|
|
10
|
-
const { moduleMap, constructorMap } = await
|
|
10
|
+
const { moduleMap, constructorMap } = await _chunkINPMEA67js.Factory.call(void 0, Modules);
|
|
11
11
|
return {
|
|
12
12
|
get(Module) {
|
|
13
13
|
const tag = _optionalChain([Module, 'access', _ => _.prototype, 'optionalAccess', _2 => _2.__TAG__]) || Module.name;
|
|
@@ -21,45 +21,47 @@ async function TestFactory(...Modules) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
_chunkGWLM5DEJjs.__name.call(void 0, TestFactory, "TestFactory");
|
|
24
|
-
async function TestHttp(app, { moduleMap, meta }) {
|
|
25
|
-
const { default: request } = await Promise.resolve().then(() => require("supertest"));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
data.params.forEach((item) => {
|
|
44
|
-
if (item.type === "params") {
|
|
45
|
-
ret.url = ret.url.replace(`:${item.key}`, args[item.index]);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (item.type === "query") {
|
|
49
|
-
ret.query[item.key] = args[item.index];
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (item.key)
|
|
53
|
-
ret[item.type][item.key] = args[item.index];
|
|
54
|
-
else
|
|
55
|
-
ret[item.type] = args[item.index];
|
|
56
|
-
});
|
|
57
|
-
return request(app)[ret.method](ret.url).query(ret.query).set(ret.headers).send(ret.body);
|
|
24
|
+
async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
25
|
+
const { default: request, agent } = await Promise.resolve().then(() => require("supertest"));
|
|
26
|
+
const Agent = agent(app);
|
|
27
|
+
function module(Module) {
|
|
28
|
+
const tag = _optionalChain([Module, 'access', _3 => _3.prototype, 'optionalAccess', _4 => _4.__TAG__]) || Module.name;
|
|
29
|
+
const instance = moduleMap.get(tag);
|
|
30
|
+
if (!instance)
|
|
31
|
+
throw new Error(`module "${tag}" doesn't exist`);
|
|
32
|
+
return new Proxy({}, {
|
|
33
|
+
get(_target, p) {
|
|
34
|
+
const { data } = meta.find(({ data: data2 }) => data2.name === Module.name && data2.method === p && data2.tag === tag);
|
|
35
|
+
return (...args) => {
|
|
36
|
+
const ret = {
|
|
37
|
+
body: {},
|
|
38
|
+
headers: {},
|
|
39
|
+
query: {},
|
|
40
|
+
method: data.http.type,
|
|
41
|
+
url: data.http.route
|
|
58
42
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
data.params.forEach((item) => {
|
|
44
|
+
if (item.type === "params") {
|
|
45
|
+
ret.url = ret.url.replace(`:${item.key}`, args[item.index]);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (item.type === "query") {
|
|
49
|
+
ret.query[item.key] = args[item.index];
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (item.key)
|
|
53
|
+
ret[item.type][item.key] = args[item.index];
|
|
54
|
+
else
|
|
55
|
+
ret[item.type] = args[item.index];
|
|
56
|
+
});
|
|
57
|
+
return (isAgent ? Agent : request(app))[ret.method](ret.url).query(ret.query).set(ret.headers).send(ret.body);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
_chunkGWLM5DEJjs.__name.call(void 0, module, "module");
|
|
63
|
+
Agent.module = module;
|
|
64
|
+
return Agent;
|
|
63
65
|
}
|
|
64
66
|
_chunkGWLM5DEJjs.__name.call(void 0, TestHttp, "TestHttp");
|
|
65
67
|
|
package/dist/test.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Factory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Y7AOZMC2.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
6
|
} from "./chunk-DJO45NRZ.mjs";
|
|
@@ -21,45 +21,47 @@ async function TestFactory(...Modules) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
__name(TestFactory, "TestFactory");
|
|
24
|
-
async function TestHttp(app, { moduleMap, meta }) {
|
|
25
|
-
const { default: request } = await import("supertest");
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
data.params.forEach((item) => {
|
|
44
|
-
if (item.type === "params") {
|
|
45
|
-
ret.url = ret.url.replace(`:${item.key}`, args[item.index]);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (item.type === "query") {
|
|
49
|
-
ret.query[item.key] = args[item.index];
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (item.key)
|
|
53
|
-
ret[item.type][item.key] = args[item.index];
|
|
54
|
-
else
|
|
55
|
-
ret[item.type] = args[item.index];
|
|
56
|
-
});
|
|
57
|
-
return request(app)[ret.method](ret.url).query(ret.query).set(ret.headers).send(ret.body);
|
|
24
|
+
async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
25
|
+
const { default: request, agent } = await import("supertest");
|
|
26
|
+
const Agent = agent(app);
|
|
27
|
+
function module(Module) {
|
|
28
|
+
const tag = Module.prototype?.__TAG__ || Module.name;
|
|
29
|
+
const instance = moduleMap.get(tag);
|
|
30
|
+
if (!instance)
|
|
31
|
+
throw new Error(`module "${tag}" doesn't exist`);
|
|
32
|
+
return new Proxy({}, {
|
|
33
|
+
get(_target, p) {
|
|
34
|
+
const { data } = meta.find(({ data: data2 }) => data2.name === Module.name && data2.method === p && data2.tag === tag);
|
|
35
|
+
return (...args) => {
|
|
36
|
+
const ret = {
|
|
37
|
+
body: {},
|
|
38
|
+
headers: {},
|
|
39
|
+
query: {},
|
|
40
|
+
method: data.http.type,
|
|
41
|
+
url: data.http.route
|
|
58
42
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
data.params.forEach((item) => {
|
|
44
|
+
if (item.type === "params") {
|
|
45
|
+
ret.url = ret.url.replace(`:${item.key}`, args[item.index]);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (item.type === "query") {
|
|
49
|
+
ret.query[item.key] = args[item.index];
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (item.key)
|
|
53
|
+
ret[item.type][item.key] = args[item.index];
|
|
54
|
+
else
|
|
55
|
+
ret[item.type] = args[item.index];
|
|
56
|
+
});
|
|
57
|
+
return (isAgent ? Agent : request(app))[ret.method](ret.url).query(ret.query).set(ret.headers).send(ret.body);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
__name(module, "module");
|
|
63
|
+
Agent.module = module;
|
|
64
|
+
return Agent;
|
|
63
65
|
}
|
|
64
66
|
__name(TestHttp, "TestHttp");
|
|
65
67
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-server",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.13",
|
|
4
4
|
"description": "provide express middlewares, `nestjs` format",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"debug": "^4.3.4",
|
|
122
122
|
"picocolors": "^1.0.0",
|
|
123
123
|
"reflect-metadata": "^0.1.13",
|
|
124
|
-
"phecda-core": "3.0.0-alpha.
|
|
124
|
+
"phecda-core": "3.0.0-alpha.7"
|
|
125
125
|
},
|
|
126
126
|
"scripts": {
|
|
127
127
|
"dev": "tsup --watch",
|