phecda-server 7.0.0-alpha.6 → 7.0.0-alpha.8
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-JF4YU32E.js → chunk-7EMAZGYO.js} +86 -56
- package/dist/{chunk-ICI5KUDX.mjs → chunk-7NWDKK7D.mjs} +1 -1
- package/dist/{chunk-HTY3H33L.mjs → chunk-B45BN7LY.mjs} +4 -4
- package/dist/{chunk-UKRQVTEY.js → chunk-BBNJVYVX.js} +24 -24
- package/dist/{chunk-WYI2F7LD.js → chunk-QJIAXSLZ.js} +19 -19
- package/dist/{chunk-3C7Z3IJN.mjs → chunk-SGMQZRP6.mjs} +39 -9
- package/dist/{chunk-62FBZWGW.js → chunk-VSGYTGHY.js} +24 -3
- package/dist/{chunk-KSDE5G57.mjs → chunk-YKP4ODZA.mjs} +24 -3
- package/dist/{core-CzElxZoF.d.ts → core-BGEsBtTG.d.ts} +1 -1
- package/dist/{core-DU7gQKSk.d.mts → core-BcKywWLd.d.mts} +1 -1
- package/dist/helper.d.mts +3 -2
- package/dist/helper.d.ts +3 -2
- package/dist/helper.js +5 -3
- package/dist/helper.mjs +4 -2
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +42 -41
- package/dist/http/elysia/index.mjs +6 -5
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +39 -38
- package/dist/http/express/index.mjs +5 -4
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +40 -39
- package/dist/http/fastify/index.mjs +6 -5
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +40 -39
- package/dist/http/h3/index.mjs +6 -5
- 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 -35
- package/dist/http/hono/index.mjs +2 -2
- 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 +37 -36
- package/dist/http/hyper-express/index.mjs +5 -4
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +39 -38
- package/dist/http/koa/index.mjs +5 -4
- package/dist/index.d.mts +38 -36
- package/dist/index.d.ts +38 -36
- package/dist/index.js +44 -43
- package/dist/index.mjs +16 -15
- package/dist/{meta-BTnLXuCa.d.ts → meta-B_HW7cWh.d.mts} +3 -3
- package/dist/{meta-BTnLXuCa.d.mts → meta-B_HW7cWh.d.ts} +3 -3
- package/dist/rpc/bullmq/index.d.mts +5 -5
- package/dist/rpc/bullmq/index.d.ts +5 -5
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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--E-OCZhC.d.ts → types-C2SQ9U9V.d.mts} +3 -3
- package/dist/{types-CbfaGkPA.d.ts → types-CYF0vha6.d.ts} +3 -3
- package/dist/{types-BYqBeqrs.d.mts → types-DEQb_e59.d.mts} +3 -3
- package/dist/{types-BxlzVoRv.d.mts → types-PFPIQWVF.d.ts} +3 -3
- package/package.json +3 -2
- package/register/loader.mjs +2 -2
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkVSGYTGHYjs = require('./chunk-VSGYTGHY.js');
|
|
7
7
|
|
|
8
8
|
// src/meta.ts
|
|
9
9
|
var Meta = class {
|
|
10
10
|
static {
|
|
11
|
-
|
|
11
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "Meta");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
@@ -37,11 +37,11 @@ function defaultServerInject() {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
_chunkVSGYTGHYjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
|
|
41
41
|
var phecdaNamespace = /* @__PURE__ */ new Map();
|
|
42
42
|
var ServerPhecda = (_class = class {
|
|
43
43
|
static {
|
|
44
|
-
|
|
44
|
+
_chunkVSGYTGHYjs.__name.call(void 0, this, "ServerPhecda");
|
|
45
45
|
}
|
|
46
46
|
__init() {this.moduleMap = /* @__PURE__ */ new Map()}
|
|
47
47
|
__init2() {this.meta = []}
|
|
@@ -53,7 +53,7 @@ var ServerPhecda = (_class = class {
|
|
|
53
53
|
|
|
54
54
|
constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);
|
|
55
55
|
defaultServerInject();
|
|
56
|
-
const { namespace = "default", parseModule = /* @__PURE__ */
|
|
56
|
+
const { namespace = "default", parseModule = /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
|
|
57
57
|
phecdaNamespace.set(namespace, this);
|
|
58
58
|
this.parseMeta = parseMeta;
|
|
59
59
|
this.parseModule = parseModule;
|
|
@@ -61,8 +61,8 @@ var ServerPhecda = (_class = class {
|
|
|
61
61
|
}
|
|
62
62
|
async start(models) {
|
|
63
63
|
for (const model of models) await this.buildDepModule(model);
|
|
64
|
-
const generateCode = /* @__PURE__ */
|
|
65
|
-
if (
|
|
64
|
+
const generateCode = /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, async () => {
|
|
65
|
+
if (_chunkVSGYTGHYjs.IS_DEV) {
|
|
66
66
|
return Promise.all(this.generators.map((generator) => {
|
|
67
67
|
debug(`generate "${generator.name}" code to ${generator.path}`);
|
|
68
68
|
return generator.output(this.meta);
|
|
@@ -70,9 +70,9 @@ var ServerPhecda = (_class = class {
|
|
|
70
70
|
}
|
|
71
71
|
}, "generateCode");
|
|
72
72
|
generateCode().then(() => {
|
|
73
|
-
if (
|
|
73
|
+
if (_chunkVSGYTGHYjs.IS_ONLY_GENERATE) process.exit(4);
|
|
74
74
|
});
|
|
75
|
-
if (
|
|
75
|
+
if (_chunkVSGYTGHYjs.IS_DEV) {
|
|
76
76
|
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
77
77
|
_optionalChain([globalThis, 'access', _2 => _2.__PS_HMR__, 'optionalAccess', _3 => _3.push, 'call', _4 => _4(async (files) => {
|
|
78
78
|
debug("reload files ");
|
|
@@ -148,7 +148,7 @@ var ServerPhecda = (_class = class {
|
|
|
148
148
|
if (this.moduleMap.has(tag)) {
|
|
149
149
|
module = this.moduleMap.get(tag);
|
|
150
150
|
if (!module) {
|
|
151
|
-
|
|
151
|
+
_chunkVSGYTGHYjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
|
|
152
152
|
return {
|
|
153
153
|
module: this.createProxyModule(tag),
|
|
154
154
|
tag
|
|
@@ -156,8 +156,8 @@ var ServerPhecda = (_class = class {
|
|
|
156
156
|
}
|
|
157
157
|
if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
|
|
158
158
|
this.modelSet.add(Model);
|
|
159
|
-
if (module instanceof Model)
|
|
160
|
-
else
|
|
159
|
+
if (module instanceof Model) _chunkVSGYTGHYjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
|
|
160
|
+
else _chunkVSGYTGHYjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
|
|
161
161
|
}
|
|
162
162
|
return {
|
|
163
163
|
module,
|
|
@@ -180,7 +180,7 @@ var ServerPhecda = (_class = class {
|
|
|
180
180
|
}
|
|
181
181
|
this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
|
|
182
182
|
debug(`init module "${String(tag)}"`);
|
|
183
|
-
if (!
|
|
183
|
+
if (!_chunkVSGYTGHYjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
|
|
184
184
|
debug(`add module "${String(tag)}"`);
|
|
185
185
|
this.moduleMap.set(tag, module);
|
|
186
186
|
this.modelMap.set(module, Model);
|
|
@@ -203,7 +203,7 @@ async function Factory(models, opts = {}) {
|
|
|
203
203
|
await phecda.start(models);
|
|
204
204
|
return phecda;
|
|
205
205
|
}
|
|
206
|
-
|
|
206
|
+
_chunkVSGYTGHYjs.__name.call(void 0, Factory, "Factory");
|
|
207
207
|
function useS(nsOrModel, namespace) {
|
|
208
208
|
if (!nsOrModel) {
|
|
209
209
|
namespace = "default";
|
|
@@ -216,7 +216,7 @@ function useS(nsOrModel, namespace) {
|
|
|
216
216
|
if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
|
|
217
217
|
else return serverPhecda;
|
|
218
218
|
}
|
|
219
|
-
|
|
219
|
+
_chunkVSGYTGHYjs.__name.call(void 0, useS, "useS");
|
|
220
220
|
function getMetaFromInstance(instance, tag, name) {
|
|
221
221
|
const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
|
|
222
222
|
const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
|
|
@@ -230,7 +230,7 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
230
230
|
func: i
|
|
231
231
|
};
|
|
232
232
|
if (baseMeta.controller) {
|
|
233
|
-
if (typeof tag !== "string")
|
|
233
|
+
if (typeof tag !== "string") _chunkVSGYTGHYjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
|
|
234
234
|
metaData.controller = baseMeta.controller;
|
|
235
235
|
metaData[baseMeta.controller] = {
|
|
236
236
|
...baseMeta[baseMeta.controller],
|
|
@@ -268,7 +268,7 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
268
268
|
return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
_chunkVSGYTGHYjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
|
|
272
272
|
function deepFreeze(object) {
|
|
273
273
|
Object.freeze(object);
|
|
274
274
|
Object.getOwnPropertyNames(object).forEach((prop) => {
|
|
@@ -276,13 +276,13 @@ function deepFreeze(object) {
|
|
|
276
276
|
});
|
|
277
277
|
return object;
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
_chunkVSGYTGHYjs.__name.call(void 0, deepFreeze, "deepFreeze");
|
|
280
280
|
function getParamTypes(Model, key) {
|
|
281
281
|
const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
|
|
282
282
|
if (typeof paramTypes === "function") return paramTypes();
|
|
283
283
|
else return paramTypes;
|
|
284
284
|
}
|
|
285
|
-
|
|
285
|
+
_chunkVSGYTGHYjs.__name.call(void 0, getParamTypes, "getParamTypes");
|
|
286
286
|
|
|
287
287
|
|
|
288
288
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ERROR_SYMBOL,
|
|
3
|
-
|
|
3
|
+
IS_DEV,
|
|
4
4
|
IS_STRICT,
|
|
5
5
|
LOG_LEVEL,
|
|
6
6
|
__name,
|
|
7
7
|
log
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YKP4ODZA.mjs";
|
|
9
9
|
|
|
10
10
|
// src/helper.ts
|
|
11
11
|
import pc2 from "picocolors";
|
|
@@ -230,10 +230,25 @@ var Context = class _Context {
|
|
|
230
230
|
};
|
|
231
231
|
static guardRecord = {};
|
|
232
232
|
static addonRecord = {};
|
|
233
|
+
ctx;
|
|
234
|
+
canGetCtx;
|
|
233
235
|
constructor(data) {
|
|
234
236
|
this.data = data;
|
|
235
|
-
|
|
237
|
+
this.canGetCtx = true;
|
|
238
|
+
if (IS_DEV)
|
|
236
239
|
data._context = this;
|
|
240
|
+
const that = this;
|
|
241
|
+
this.ctx = new Proxy(data, {
|
|
242
|
+
get(target, p) {
|
|
243
|
+
if (IS_DEV && !that.canGetCtx) throw new FrameworkException("ctx must be obtained within the same request cycle in controller");
|
|
244
|
+
if (!(p in target)) log(`attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
|
|
245
|
+
return target[p];
|
|
246
|
+
},
|
|
247
|
+
set(target, p, newValue) {
|
|
248
|
+
target[p] = newValue;
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
237
252
|
}
|
|
238
253
|
static getAop(meta, opts) {
|
|
239
254
|
const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
|
|
@@ -269,14 +284,20 @@ ${pc.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
269
284
|
if (index === guards.length) {
|
|
270
285
|
const instance = moduleMap.get(tag);
|
|
271
286
|
if (ctxs) {
|
|
272
|
-
ctxs.forEach((ctx) => instance[ctx] = this.
|
|
287
|
+
ctxs.forEach((ctx) => instance[ctx] = this.ctx);
|
|
273
288
|
}
|
|
274
289
|
const args = await Promise.all(params.map((item, i) => pipe[i]({
|
|
275
290
|
arg: resolveDep(this.data[item.type], item.key),
|
|
276
291
|
reflect: paramsType[item.index],
|
|
277
292
|
...item
|
|
278
|
-
}, this.
|
|
293
|
+
}, this.ctx)));
|
|
294
|
+
if (IS_DEV) {
|
|
295
|
+
Promise.resolve().then(() => {
|
|
296
|
+
this.canGetCtx = false;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
279
299
|
res = await instance[func](...args);
|
|
300
|
+
this.canGetCtx = true;
|
|
280
301
|
} else {
|
|
281
302
|
let nextPromise;
|
|
282
303
|
async function next() {
|
|
@@ -289,7 +310,7 @@ ${pc.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
289
310
|
});
|
|
290
311
|
}
|
|
291
312
|
__name(next, "next");
|
|
292
|
-
const ret = await guards[index](this.
|
|
313
|
+
const ret = await guards[index](this.ctx, next);
|
|
293
314
|
if (ret !== void 0) {
|
|
294
315
|
res = ret;
|
|
295
316
|
} else {
|
|
@@ -302,7 +323,7 @@ ${pc.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
302
323
|
await nextHandler(0)();
|
|
303
324
|
return successCb(res);
|
|
304
325
|
} catch (e) {
|
|
305
|
-
const err = await filter(e, this.
|
|
326
|
+
const err = await filter(e, this.ctx);
|
|
306
327
|
return failCb(err);
|
|
307
328
|
}
|
|
308
329
|
}
|
|
@@ -358,7 +379,7 @@ __name(addAddon, "addAddon");
|
|
|
358
379
|
|
|
359
380
|
// src/hmr.ts
|
|
360
381
|
function HMR(cb) {
|
|
361
|
-
if (
|
|
382
|
+
if (IS_DEV) globalThis.__PS_HMR__?.push(cb);
|
|
362
383
|
}
|
|
363
384
|
__name(HMR, "HMR");
|
|
364
385
|
|
|
@@ -498,6 +519,14 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
498
519
|
};
|
|
499
520
|
}
|
|
500
521
|
__name(detectAopDep, "detectAopDep");
|
|
522
|
+
function joinUrl(base, ...paths) {
|
|
523
|
+
const joinedPath = [
|
|
524
|
+
base,
|
|
525
|
+
...paths
|
|
526
|
+
].filter((p) => p).map((path) => path.replace(/(^\/)/g, "")).join("/");
|
|
527
|
+
return `/${joinedPath}`;
|
|
528
|
+
}
|
|
529
|
+
__name(joinUrl, "joinUrl");
|
|
501
530
|
|
|
502
531
|
export {
|
|
503
532
|
defaultPipe,
|
|
@@ -530,5 +559,6 @@ export {
|
|
|
530
559
|
shallowClone,
|
|
531
560
|
mergeObject,
|
|
532
561
|
createControllerMetaMap,
|
|
533
|
-
detectAopDep
|
|
562
|
+
detectAopDep,
|
|
563
|
+
joinUrl
|
|
534
564
|
};
|
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/common.ts
|
|
5
5
|
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var
|
|
6
|
+
var IS_DEV = process.env.NODE_ENV === "development";
|
|
7
7
|
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
9
|
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
@@ -17,6 +17,14 @@ var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
|
17
17
|
// src/utils.ts
|
|
18
18
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
19
19
|
var _tsmixer = require('ts-mixer');
|
|
20
|
+
var isObject = /* @__PURE__ */ __name((fn) => fn !== null && typeof fn === "object", "isObject");
|
|
21
|
+
var isPlainObject = /* @__PURE__ */ __name((fn) => {
|
|
22
|
+
if (!isObject(fn)) return false;
|
|
23
|
+
const proto = Object.getPrototypeOf(fn);
|
|
24
|
+
if (proto === null) return true;
|
|
25
|
+
const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
26
|
+
return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
|
|
27
|
+
}, "isPlainObject");
|
|
20
28
|
var InternalLogger = (_class = class InternalLogger2 {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
|
|
21
29
|
static {
|
|
22
30
|
__name(this, "InternalLogger");
|
|
@@ -58,9 +66,22 @@ var InternalLogger = (_class = class InternalLogger2 {constructor() { _class.pro
|
|
|
58
66
|
if (logLevel < LOG_LEVEL) return false;
|
|
59
67
|
return true;
|
|
60
68
|
}
|
|
69
|
+
stringifyMessage(message, logLevel) {
|
|
70
|
+
if (typeof message === "function") {
|
|
71
|
+
const messageAsStr = Function.prototype.toString.call(message);
|
|
72
|
+
const isClass = messageAsStr.startsWith("class ");
|
|
73
|
+
if (isClass) {
|
|
74
|
+
return this.stringifyMessage(message.name, logLevel);
|
|
75
|
+
}
|
|
76
|
+
return this.stringifyMessage(message(), logLevel);
|
|
77
|
+
}
|
|
78
|
+
return isPlainObject(message) || Array.isArray(message) ? `${this.colorize("Object:", logLevel)}
|
|
79
|
+
${JSON.stringify(message, (key, value) => typeof value === "bigint" ? value.toString() : value, 2)}
|
|
80
|
+
` : this.colorize(message, logLevel);
|
|
81
|
+
}
|
|
61
82
|
log(msg, level, ctx) {
|
|
62
83
|
if (!this.isAllowLog(level)) return;
|
|
63
|
-
msg = this.
|
|
84
|
+
msg = this.stringifyMessage(msg, level);
|
|
64
85
|
const pidMsg = this.colorize(`[phecda-server] ${process.pid}`, level);
|
|
65
86
|
const ctxMsg = ctx ? this.colorize(_picocolors2.default.bold(`[${ctx}] `), level) : "";
|
|
66
87
|
const timeDiff = this.diffTimestamp();
|
|
@@ -103,4 +124,4 @@ __name(runMiddleware, "runMiddleware");
|
|
|
103
124
|
|
|
104
125
|
|
|
105
126
|
|
|
106
|
-
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.
|
|
127
|
+
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_DEV = IS_DEV; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.LOG_LEVEL = LOG_LEVEL; exports.IS_READY = IS_READY; exports.PS_EXIT_CODE = PS_EXIT_CODE; exports.setLogger = setLogger; exports.getLogger = getLogger; exports.log = log; exports.runMiddleware = runMiddleware; exports.Mixin = _tsmixer.Mixin;
|
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/common.ts
|
|
5
5
|
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var
|
|
6
|
+
var IS_DEV = process.env.NODE_ENV === "development";
|
|
7
7
|
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
9
|
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
@@ -17,6 +17,14 @@ var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
|
17
17
|
// src/utils.ts
|
|
18
18
|
import pc from "picocolors";
|
|
19
19
|
import { Mixin } from "ts-mixer";
|
|
20
|
+
var isObject = /* @__PURE__ */ __name((fn) => fn !== null && typeof fn === "object", "isObject");
|
|
21
|
+
var isPlainObject = /* @__PURE__ */ __name((fn) => {
|
|
22
|
+
if (!isObject(fn)) return false;
|
|
23
|
+
const proto = Object.getPrototypeOf(fn);
|
|
24
|
+
if (proto === null) return true;
|
|
25
|
+
const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
26
|
+
return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
|
|
27
|
+
}, "isPlainObject");
|
|
20
28
|
var InternalLogger = class InternalLogger2 {
|
|
21
29
|
static {
|
|
22
30
|
__name(this, "InternalLogger");
|
|
@@ -58,9 +66,22 @@ var InternalLogger = class InternalLogger2 {
|
|
|
58
66
|
if (logLevel < LOG_LEVEL) return false;
|
|
59
67
|
return true;
|
|
60
68
|
}
|
|
69
|
+
stringifyMessage(message, logLevel) {
|
|
70
|
+
if (typeof message === "function") {
|
|
71
|
+
const messageAsStr = Function.prototype.toString.call(message);
|
|
72
|
+
const isClass = messageAsStr.startsWith("class ");
|
|
73
|
+
if (isClass) {
|
|
74
|
+
return this.stringifyMessage(message.name, logLevel);
|
|
75
|
+
}
|
|
76
|
+
return this.stringifyMessage(message(), logLevel);
|
|
77
|
+
}
|
|
78
|
+
return isPlainObject(message) || Array.isArray(message) ? `${this.colorize("Object:", logLevel)}
|
|
79
|
+
${JSON.stringify(message, (key, value) => typeof value === "bigint" ? value.toString() : value, 2)}
|
|
80
|
+
` : this.colorize(message, logLevel);
|
|
81
|
+
}
|
|
61
82
|
log(msg, level, ctx) {
|
|
62
83
|
if (!this.isAllowLog(level)) return;
|
|
63
|
-
msg = this.
|
|
84
|
+
msg = this.stringifyMessage(msg, level);
|
|
64
85
|
const pidMsg = this.colorize(`[phecda-server] ${process.pid}`, level);
|
|
65
86
|
const ctxMsg = ctx ? this.colorize(pc.bold(`[${ctx}] `), level) : "";
|
|
66
87
|
const timeDiff = this.diffTimestamp();
|
|
@@ -92,7 +113,7 @@ __name(runMiddleware, "runMiddleware");
|
|
|
92
113
|
export {
|
|
93
114
|
__name,
|
|
94
115
|
ERROR_SYMBOL,
|
|
95
|
-
|
|
116
|
+
IS_DEV,
|
|
96
117
|
IS_ONLY_GENERATE,
|
|
97
118
|
IS_STRICT,
|
|
98
119
|
LOG_LEVEL,
|
package/dist/helper.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-
|
|
1
|
+
import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-B_HW7cWh.mjs';
|
|
2
2
|
import 'phecda-core';
|
|
3
3
|
|
|
4
4
|
declare function HMR(cb: (...args: any) => any): void;
|
|
@@ -21,5 +21,6 @@ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
|
|
|
21
21
|
pipeSet: Set<string>;
|
|
22
22
|
filterSet: Set<string>;
|
|
23
23
|
};
|
|
24
|
+
declare function joinUrl(base: string, ...paths: string[]): string;
|
|
24
25
|
|
|
25
|
-
export { HMR, argToReq, createControllerMetaMap, detectAopDep, genClientQueue, mergeObject, resolveDep, shallowClone };
|
|
26
|
+
export { HMR, argToReq, createControllerMetaMap, detectAopDep, genClientQueue, joinUrl, mergeObject, resolveDep, shallowClone };
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-
|
|
1
|
+
import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-B_HW7cWh.js';
|
|
2
2
|
import 'phecda-core';
|
|
3
3
|
|
|
4
4
|
declare function HMR(cb: (...args: any) => any): void;
|
|
@@ -21,5 +21,6 @@ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
|
|
|
21
21
|
pipeSet: Set<string>;
|
|
22
22
|
filterSet: Set<string>;
|
|
23
23
|
};
|
|
24
|
+
declare function joinUrl(base: string, ...paths: string[]): string;
|
|
24
25
|
|
|
25
|
-
export { HMR, argToReq, createControllerMetaMap, detectAopDep, genClientQueue, mergeObject, resolveDep, shallowClone };
|
|
26
|
+
export { HMR, argToReq, createControllerMetaMap, detectAopDep, genClientQueue, joinUrl, mergeObject, resolveDep, shallowClone };
|
package/dist/helper.js
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var _chunkJF4YU32Ejs = require('./chunk-JF4YU32E.js');
|
|
11
|
-
require('./chunk-62FBZWGW.js');
|
|
12
10
|
|
|
11
|
+
var _chunk7EMAZGYOjs = require('./chunk-7EMAZGYO.js');
|
|
12
|
+
require('./chunk-VSGYTGHY.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -18,4 +18,6 @@ require('./chunk-62FBZWGW.js');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
exports.HMR = _chunk7EMAZGYOjs.HMR; exports.argToReq = _chunk7EMAZGYOjs.argToReq; exports.createControllerMetaMap = _chunk7EMAZGYOjs.createControllerMetaMap; exports.detectAopDep = _chunk7EMAZGYOjs.detectAopDep; exports.genClientQueue = _chunk7EMAZGYOjs.genClientQueue; exports.joinUrl = _chunk7EMAZGYOjs.joinUrl; exports.mergeObject = _chunk7EMAZGYOjs.mergeObject; exports.resolveDep = _chunk7EMAZGYOjs.resolveDep; exports.shallowClone = _chunk7EMAZGYOjs.shallowClone;
|
package/dist/helper.mjs
CHANGED
|
@@ -4,17 +4,19 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue,
|
|
7
|
+
joinUrl,
|
|
7
8
|
mergeObject,
|
|
8
9
|
resolveDep,
|
|
9
10
|
shallowClone
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-SGMQZRP6.mjs";
|
|
12
|
+
import "./chunk-YKP4ODZA.mjs";
|
|
12
13
|
export {
|
|
13
14
|
HMR,
|
|
14
15
|
argToReq,
|
|
15
16
|
createControllerMetaMap,
|
|
16
17
|
detectAopDep,
|
|
17
18
|
genClientQueue,
|
|
19
|
+
joinUrl,
|
|
18
20
|
mergeObject,
|
|
19
21
|
resolveDep,
|
|
20
22
|
shallowClone
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-C2SQ9U9V.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-BcKywWLd.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-B_HW7cWh.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
|
-
interface ElysiaCtx extends
|
|
9
|
+
interface ElysiaCtx extends HttpCtx {
|
|
10
10
|
type: 'elysia';
|
|
11
11
|
app: Elysia$1;
|
|
12
12
|
context: Context;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpCtx, a as HttpOptions } from '../../types-PFPIQWVF.js';
|
|
4
|
+
import { F as Factory } from '../../core-BGEsBtTG.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-B_HW7cWh.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
|
-
interface ElysiaCtx extends
|
|
9
|
+
interface ElysiaCtx extends HttpCtx {
|
|
10
10
|
type: 'elysia';
|
|
11
11
|
app: Elysia$1;
|
|
12
12
|
context: Context;
|