phecda-server 5.0.0-alpha.16 → 5.0.0-alpha.17

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.
@@ -8,10 +8,8 @@ var _chunkT4C6CCWMjs = require('./chunk-T4C6CCWM.js');
8
8
  var Meta = class {
9
9
 
10
10
 
11
-
12
- constructor(data, handlers, paramsType) {
11
+ constructor(data, paramsType) {
13
12
  this.data = data;
14
- this.handlers = handlers;
15
13
  this.paramsType = paramsType;
16
14
  }
17
15
  };
@@ -313,7 +311,7 @@ function getMetaFromInstance(instance, tag, name) {
313
311
  ...state.interceptors
314
312
  ])
315
313
  ];
316
- return new Meta(meta, _phecdacore.getHandler.call(void 0, instance, i), getParamTypes(instance, i) || []);
314
+ return new Meta(meta, getParamTypes(instance, i) || []);
317
315
  });
318
316
  }
319
317
  _chunkT4C6CCWMjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
@@ -7,11 +7,9 @@ import {
7
7
  // src/meta.ts
8
8
  var Meta = class {
9
9
  data;
10
- handlers;
11
10
  paramsType;
12
- constructor(data, handlers, paramsType) {
11
+ constructor(data, paramsType) {
13
12
  this.data = data;
14
- this.handlers = handlers;
15
13
  this.paramsType = paramsType;
16
14
  }
17
15
  };
@@ -102,7 +100,7 @@ __name(generateHTTPCode, "generateHTTPCode");
102
100
  import "reflect-metadata";
103
101
  import fs from "fs";
104
102
  import EventEmitter from "node:events";
105
- import { Empty, SHARE_KEY, getExposeKey, getHandler, getProperty, getState, getTag, injectProperty, invokeHandler, isPhecda } from "phecda-core";
103
+ import { Empty, SHARE_KEY, getExposeKey, getProperty, getState, getTag, injectProperty, invokeHandler, isPhecda } from "phecda-core";
106
104
  import Debug from "debug";
107
105
  function Injectable() {
108
106
  return (target) => Empty(target);
@@ -313,7 +311,7 @@ function getMetaFromInstance(instance, tag, name) {
313
311
  ...state.interceptors
314
312
  ])
315
313
  ];
316
- return new Meta(meta, getHandler(instance, i), getParamTypes(instance, i) || []);
314
+ return new Meta(meta, getParamTypes(instance, i) || []);
317
315
  });
318
316
  }
319
317
  __name(getMetaFromInstance, "getMetaFromInstance");
@@ -28,9 +28,8 @@ declare const PS_IMPORT_RE: RegExp;
28
28
 
29
29
  declare class Meta {
30
30
  data: P.MetaData;
31
- handlers: P.Handler[];
32
31
  paramsType: any[];
33
- constructor(data: P.MetaData, handlers: P.Handler[], paramsType: any[]);
32
+ constructor(data: P.MetaData, paramsType: any[]);
34
33
  }
35
34
 
36
35
  interface Emitter {
@@ -87,9 +86,6 @@ declare namespace P {
87
86
  reflect: any;
88
87
  }, ctx: C) => Promise<any>;
89
88
  type Filter<C extends BaseContext = any, E extends Exception = any> = (err: E | Error, ctx?: C) => Error | any;
90
- interface Handler {
91
- error?: (arg: any) => void;
92
- }
93
89
  interface MetaData {
94
90
  http?: {
95
91
  type: RequestType;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Exception, P, M as Meta, U as UNMOUNT_SYMBOL } from './core-b8dcc009.js';
2
- export { A as APP_SYMBOL, k as ERROR_SYMBOL, a as Emitter, F as Factory, h as IS_DEV, j as IS_LOG_BAN, i as IS_STRICT, I as Injectable, d as MERGE_SYMBOL, g as META_SYMBOL, f as MODULE_SYMBOL, l as PS_FILE_RE, m as PS_IMPORT_RE, c as PickFunc, b as PickKeysByValue, R as RequestType, T as ToControllerMap, e as emitter } from './core-b8dcc009.js';
1
+ import { E as Exception, P, M as Meta, U as UNMOUNT_SYMBOL } from './core-eb2a0799.js';
2
+ export { A as APP_SYMBOL, k as ERROR_SYMBOL, a as Emitter, F as Factory, h as IS_DEV, j as IS_LOG_BAN, i as IS_STRICT, I as Injectable, d as MERGE_SYMBOL, g as META_SYMBOL, f as MODULE_SYMBOL, l as PS_FILE_RE, m as PS_IMPORT_RE, c as PickFunc, b as PickKeysByValue, R as RequestType, T as ToControllerMap, e as emitter } from './core-eb2a0799.js';
3
3
  import { Construct, AbConstruct } from 'phecda-core';
4
4
  export * from 'phecda-core';
5
5
  import 'node:http';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkRQOJIVQMjs = require('./chunk-RQOJIVQM.js');
8
+ var _chunkC37JSJDOjs = require('./chunk-C37JSJDO.js');
9
9
 
10
10
 
11
11
 
@@ -511,4 +511,4 @@ _chunkT4C6CCWMjs.__name.call(void 0, PExtension, "PExtension");
511
511
 
512
512
 
513
513
 
514
- exports.APP_SYMBOL = _chunkT4C6CCWMjs.APP_SYMBOL; exports.Arg = Arg; exports.BadGatewayException = _chunkVUOACQPJjs.BadGatewayException; exports.BadRequestException = _chunkVUOACQPJjs.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunkVUOACQPJjs.ConflictException; exports.Context = _chunkVUOACQPJjs.Context; exports.Controller = Controller; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkT4C6CCWMjs.ERROR_SYMBOL; exports.Event = Event; exports.Exception = _chunkVUOACQPJjs.Exception; exports.Factory = _chunkRQOJIVQMjs.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunkVUOACQPJjs.ForbiddenException; exports.FrameworkException = _chunkVUOACQPJjs.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkT4C6CCWMjs.IS_DEV; exports.IS_LOG_BAN = _chunkT4C6CCWMjs.IS_LOG_BAN; exports.IS_STRICT = _chunkT4C6CCWMjs.IS_STRICT; exports.Injectable = _chunkRQOJIVQMjs.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunkVUOACQPJjs.InvalidInputException; exports.MERGE_SYMBOL = _chunkT4C6CCWMjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkT4C6CCWMjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkT4C6CCWMjs.MODULE_SYMBOL; exports.Meta = _chunkRQOJIVQMjs.Meta; exports.Mix = _chunkT4C6CCWMjs.Mix; exports.NotFoundException = _chunkVUOACQPJjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_FILE_RE = _chunkT4C6CCWMjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkT4C6CCWMjs.PS_IMPORT_RE; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunkVUOACQPJjs.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunkVUOACQPJjs.ServiceUnavailableException; exports.TimeoutException = _chunkVUOACQPJjs.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkT4C6CCWMjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkVUOACQPJjs.UnauthorizedException; exports.UndefinedException = _chunkVUOACQPJjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkVUOACQPJjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkVUOACQPJjs.ValidateException; exports.addFilter = _chunkVUOACQPJjs.addFilter; exports.addGuard = _chunkVUOACQPJjs.addGuard; exports.addInterceptor = _chunkVUOACQPJjs.addInterceptor; exports.addPipe = _chunkVUOACQPJjs.addPipe; exports.addPlugin = _chunkVUOACQPJjs.addPlugin; exports.argToReq = _chunkCRAV4WSBjs.argToReq; exports.defaultPipe = _chunkVUOACQPJjs.defaultPipe; exports.emitter = _chunkRQOJIVQMjs.emitter; exports.generateHTTPCode = _chunkRQOJIVQMjs.generateHTTPCode; exports.generateRPCCode = _chunkRQOJIVQMjs.generateRPCCode; exports.getConfig = _chunkT4C6CCWMjs.getConfig; exports.guardRecord = _chunkVUOACQPJjs.guardRecord; exports.isAopDepInject = _chunkVUOACQPJjs.isAopDepInject; exports.log = _chunkT4C6CCWMjs.log; exports.resolveDep = _chunkCRAV4WSBjs.resolveDep; exports.setConfig = _chunkT4C6CCWMjs.setConfig;
514
+ exports.APP_SYMBOL = _chunkT4C6CCWMjs.APP_SYMBOL; exports.Arg = Arg; exports.BadGatewayException = _chunkVUOACQPJjs.BadGatewayException; exports.BadRequestException = _chunkVUOACQPJjs.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunkVUOACQPJjs.ConflictException; exports.Context = _chunkVUOACQPJjs.Context; exports.Controller = Controller; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkT4C6CCWMjs.ERROR_SYMBOL; exports.Event = Event; exports.Exception = _chunkVUOACQPJjs.Exception; exports.Factory = _chunkC37JSJDOjs.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunkVUOACQPJjs.ForbiddenException; exports.FrameworkException = _chunkVUOACQPJjs.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkT4C6CCWMjs.IS_DEV; exports.IS_LOG_BAN = _chunkT4C6CCWMjs.IS_LOG_BAN; exports.IS_STRICT = _chunkT4C6CCWMjs.IS_STRICT; exports.Injectable = _chunkC37JSJDOjs.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunkVUOACQPJjs.InvalidInputException; exports.MERGE_SYMBOL = _chunkT4C6CCWMjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkT4C6CCWMjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkT4C6CCWMjs.MODULE_SYMBOL; exports.Meta = _chunkC37JSJDOjs.Meta; exports.Mix = _chunkT4C6CCWMjs.Mix; exports.NotFoundException = _chunkVUOACQPJjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_FILE_RE = _chunkT4C6CCWMjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkT4C6CCWMjs.PS_IMPORT_RE; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunkVUOACQPJjs.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunkVUOACQPJjs.ServiceUnavailableException; exports.TimeoutException = _chunkVUOACQPJjs.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkT4C6CCWMjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkVUOACQPJjs.UnauthorizedException; exports.UndefinedException = _chunkVUOACQPJjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkVUOACQPJjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkVUOACQPJjs.ValidateException; exports.addFilter = _chunkVUOACQPJjs.addFilter; exports.addGuard = _chunkVUOACQPJjs.addGuard; exports.addInterceptor = _chunkVUOACQPJjs.addInterceptor; exports.addPipe = _chunkVUOACQPJjs.addPipe; exports.addPlugin = _chunkVUOACQPJjs.addPlugin; exports.argToReq = _chunkCRAV4WSBjs.argToReq; exports.defaultPipe = _chunkVUOACQPJjs.defaultPipe; exports.emitter = _chunkC37JSJDOjs.emitter; exports.generateHTTPCode = _chunkC37JSJDOjs.generateHTTPCode; exports.generateRPCCode = _chunkC37JSJDOjs.generateRPCCode; exports.getConfig = _chunkT4C6CCWMjs.getConfig; exports.guardRecord = _chunkVUOACQPJjs.guardRecord; exports.isAopDepInject = _chunkVUOACQPJjs.isAopDepInject; exports.log = _chunkT4C6CCWMjs.log; exports.resolveDep = _chunkCRAV4WSBjs.resolveDep; exports.setConfig = _chunkT4C6CCWMjs.setConfig;
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  emitter,
6
6
  generateHTTPCode,
7
7
  generateRPCCode
8
- } from "./chunk-CPTMTSPU.mjs";
8
+ } from "./chunk-D26I5GHO.mjs";
9
9
  import {
10
10
  argToReq,
11
11
  resolveDep
@@ -1,5 +1,5 @@
1
1
  import { Kafka } from 'kafkajs';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-b8dcc009.js';
2
+ import { P, F as Factory, T as ToControllerMap } from '../../core-eb2a0799.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import amqplib from 'amqplib';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-b8dcc009.js';
2
+ import { P, F as Factory, T as ToControllerMap } from '../../core-eb2a0799.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-b8dcc009.js';
2
+ import { P, F as Factory, T as ToControllerMap } from '../../core-eb2a0799.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Request, Response, Router } from 'express';
2
- import { P, F as Factory } from '../../core-b8dcc009.js';
2
+ import { P, F as Factory } from '../../core-eb2a0799.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -7,6 +7,7 @@ interface ExpressCtx extends P.HttpContext {
7
7
  type: 'express';
8
8
  request: Request;
9
9
  response: Response;
10
+ next: Function;
10
11
  }
11
12
  interface Options {
12
13
  route?: string;
@@ -52,7 +52,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
52
52
  req[_chunkT4C6CCWMjs.MODULE_SYMBOL] = moduleMap;
53
53
  req[_chunkT4C6CCWMjs.META_SYMBOL] = meta;
54
54
  next();
55
- }, ..._chunkVUOACQPJjs.Context.usePlugin(plugins), async (req, res) => {
55
+ }, ..._chunkVUOACQPJjs.Context.usePlugin(plugins), async (req, res, next) => {
56
56
  const { body } = req;
57
57
  async function errorHandler(e) {
58
58
  const error = await _chunkVUOACQPJjs.Context.filterRecord.default(e);
@@ -69,7 +69,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
69
69
  if (!meta2)
70
70
  return resolve(await _chunkVUOACQPJjs.Context.filterRecord.default(new (0, _chunkVUOACQPJjs.BadRequestException)(`"${tag}" doesn't exist`)));
71
71
  const [name, method] = tag.split("-");
72
- const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
72
+ const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
73
73
  const instance = moduleMap.get(name);
74
74
  const contextData = {
75
75
  type: "express",
@@ -79,6 +79,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
79
79
  response: res,
80
80
  moduleMap,
81
81
  tag,
82
+ next,
82
83
  ..._chunkCRAV4WSBjs.argToReq.call(void 0, params, item.args, req.headers)
83
84
  };
84
85
  const context = new (0, _chunkVUOACQPJjs.Context)(contextData);
@@ -108,7 +109,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
108
109
  const funcData = await moduleMap.get(name)[method](...args);
109
110
  resolve(await context.usePostInterceptor(funcData));
110
111
  } catch (e) {
111
- handlers.forEach((handler) => _optionalChain([handler, 'access', _2 => _2.error, 'optionalCall', _3 => _3(e)]));
112
112
  resolve(await context.useFilter(e, filter));
113
113
  }
114
114
  });
@@ -121,15 +121,15 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
121
121
  });
122
122
  for (const i of meta) {
123
123
  const { method, http, header, tag } = i.data;
124
- if (!_optionalChain([http, 'optionalAccess', _4 => _4.type]))
124
+ if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
125
125
  continue;
126
126
  const methodTag = `${tag}-${method}`;
127
- const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
127
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
128
128
  app[http.type](http.route, (req, _res, next) => {
129
129
  req[_chunkT4C6CCWMjs.MODULE_SYMBOL] = moduleMap;
130
130
  req[_chunkT4C6CCWMjs.META_SYMBOL] = meta;
131
131
  next();
132
- }, ..._chunkVUOACQPJjs.Context.usePlugin(plugins2), async (req, res) => {
132
+ }, ..._chunkVUOACQPJjs.Context.usePlugin(plugins2), async (req, res, next) => {
133
133
  const instance = moduleMap.get(tag);
134
134
  const contextData = {
135
135
  type: "express",
@@ -142,7 +142,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
142
142
  query: req.query,
143
143
  body: req.body,
144
144
  params: req.params,
145
- headers: req.headers
145
+ headers: req.headers,
146
+ next
146
147
  };
147
148
  const context = new (0, _chunkVUOACQPJjs.Context)(contextData);
148
149
  try {
@@ -184,7 +185,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
184
185
  else
185
186
  res.json(ret);
186
187
  } catch (e) {
187
- handlers.forEach((handler) => _optionalChain([handler, 'access', _5 => _5.error, 'optionalCall', _6 => _6(e)]));
188
188
  const err = await context.useFilter(e, filter);
189
189
  if (res.writableEnded)
190
190
  return;
@@ -197,7 +197,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
197
197
  handleMeta();
198
198
  createRoute();
199
199
  if (_chunkT4C6CCWMjs.IS_DEV) {
200
- _optionalChain([globalThis, 'access', _7 => _7.__PS_HMR__, 'optionalAccess', _8 => _8.push, 'call', _9 => _9(async () => {
200
+ _optionalChain([globalThis, 'access', _3 => _3.__PS_HMR__, 'optionalAccess', _4 => _4.push, 'call', _5 => _5(async () => {
201
201
  _chunkVUOACQPJjs.isAopDepInject.call(void 0, meta, {
202
202
  plugins,
203
203
  guards: globalGuards,
@@ -52,7 +52,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
52
52
  req[MODULE_SYMBOL] = moduleMap;
53
53
  req[META_SYMBOL] = meta;
54
54
  next();
55
- }, ...Context.usePlugin(plugins), async (req, res) => {
55
+ }, ...Context.usePlugin(plugins), async (req, res, next) => {
56
56
  const { body } = req;
57
57
  async function errorHandler(e) {
58
58
  const error = await Context.filterRecord.default(e);
@@ -69,7 +69,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
69
69
  if (!meta2)
70
70
  return resolve(await Context.filterRecord.default(new BadRequestException(`"${tag}" doesn't exist`)));
71
71
  const [name, method] = tag.split("-");
72
- const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
72
+ const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
73
73
  const instance = moduleMap.get(name);
74
74
  const contextData = {
75
75
  type: "express",
@@ -79,6 +79,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
79
79
  response: res,
80
80
  moduleMap,
81
81
  tag,
82
+ next,
82
83
  ...argToReq(params, item.args, req.headers)
83
84
  };
84
85
  const context = new Context(contextData);
@@ -108,7 +109,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
108
109
  const funcData = await moduleMap.get(name)[method](...args);
109
110
  resolve(await context.usePostInterceptor(funcData));
110
111
  } catch (e) {
111
- handlers.forEach((handler) => handler.error?.(e));
112
112
  resolve(await context.useFilter(e, filter));
113
113
  }
114
114
  });
@@ -124,12 +124,12 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
124
124
  if (!http?.type)
125
125
  continue;
126
126
  const methodTag = `${tag}-${method}`;
127
- const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
127
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
128
128
  app[http.type](http.route, (req, _res, next) => {
129
129
  req[MODULE_SYMBOL] = moduleMap;
130
130
  req[META_SYMBOL] = meta;
131
131
  next();
132
- }, ...Context.usePlugin(plugins2), async (req, res) => {
132
+ }, ...Context.usePlugin(plugins2), async (req, res, next) => {
133
133
  const instance = moduleMap.get(tag);
134
134
  const contextData = {
135
135
  type: "express",
@@ -142,7 +142,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
142
142
  query: req.query,
143
143
  body: req.body,
144
144
  params: req.params,
145
- headers: req.headers
145
+ headers: req.headers,
146
+ next
146
147
  };
147
148
  const context = new Context(contextData);
148
149
  try {
@@ -184,7 +185,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
184
185
  else
185
186
  res.json(ret);
186
187
  } catch (e) {
187
- handlers.forEach((handler) => handler.error?.(e));
188
188
  const err = await context.useFilter(e, filter);
189
189
  if (res.writableEnded)
190
190
  return;
@@ -1,5 +1,5 @@
1
1
  import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback } from 'fastify';
2
- import { P, F as Factory } from '../../core-b8dcc009.js';
2
+ import { P, F as Factory } from '../../core-eb2a0799.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -78,7 +78,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
78
78
  if (!meta2)
79
79
  return resolve(await _chunkVUOACQPJjs.Context.filterRecord.default(new (0, _chunkVUOACQPJjs.BadRequestException)(`"${tag}" doesn't exist`)));
80
80
  const [name, method] = tag.split("-");
81
- const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
81
+ const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
82
82
  const instance = moduleMap.get(name);
83
83
  const contextData = {
84
84
  type: "fastify",
@@ -119,7 +119,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
119
119
  const funcData = await moduleMap.get(name)[method](...args);
120
120
  resolve(await context.usePostInterceptor(funcData));
121
121
  } catch (e) {
122
- handlers.forEach((handler) => _optionalChain([handler, 'access', _3 => _3.error, 'optionalCall', _4 => _4(e)]));
123
122
  resolve(await context.useFilter(e, filter));
124
123
  }
125
124
  });
@@ -134,10 +133,10 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
134
133
  });
135
134
  for (const i of meta) {
136
135
  const { method, http, header, tag } = i.data;
137
- if (!_optionalChain([http, 'optionalAccess', _5 => _5.type]))
136
+ if (!_optionalChain([http, 'optionalAccess', _3 => _3.type]))
138
137
  continue;
139
138
  const methodTag = `${tag}-${method}`;
140
- const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
139
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
141
140
  fastify.register((fastify2, _opts, done2) => {
142
141
  _chunkVUOACQPJjs.Context.usePlugin(plugins2).forEach((p) => {
143
142
  p[Symbol.for("skip-override")] = true;
@@ -191,7 +190,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
191
190
  return;
192
191
  return ret;
193
192
  } catch (e) {
194
- handlers.forEach((handler) => _optionalChain([handler, 'access', _6 => _6.error, 'optionalCall', _7 => _7(e)]));
195
193
  const err = await context.useFilter(e, filter);
196
194
  if (res.sent)
197
195
  return;
@@ -203,7 +201,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
203
201
  }
204
202
  done();
205
203
  if (_chunkT4C6CCWMjs.IS_DEV) {
206
- _optionalChain([globalThis, 'access', _8 => _8.__PS_HMR__, 'optionalAccess', _9 => _9.push, 'call', _10 => _10(async () => {
204
+ _optionalChain([globalThis, 'access', _4 => _4.__PS_HMR__, 'optionalAccess', _5 => _5.push, 'call', _6 => _6(async () => {
207
205
  _chunkVUOACQPJjs.isAopDepInject.call(void 0, meta, {
208
206
  plugins,
209
207
  guards: globalGuards,
@@ -78,7 +78,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
78
78
  if (!meta2)
79
79
  return resolve(await Context.filterRecord.default(new BadRequestException(`"${tag}" doesn't exist`)));
80
80
  const [name, method] = tag.split("-");
81
- const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
81
+ const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
82
82
  const instance = moduleMap.get(name);
83
83
  const contextData = {
84
84
  type: "fastify",
@@ -119,7 +119,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
119
119
  const funcData = await moduleMap.get(name)[method](...args);
120
120
  resolve(await context.usePostInterceptor(funcData));
121
121
  } catch (e) {
122
- handlers.forEach((handler) => handler.error?.(e));
123
122
  resolve(await context.useFilter(e, filter));
124
123
  }
125
124
  });
@@ -137,7 +136,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
137
136
  if (!http?.type)
138
137
  continue;
139
138
  const methodTag = `${tag}-${method}`;
140
- const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
139
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
141
140
  fastify.register((fastify2, _opts, done2) => {
142
141
  Context.usePlugin(plugins2).forEach((p) => {
143
142
  p[Symbol.for("skip-override")] = true;
@@ -191,7 +190,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
191
190
  return;
192
191
  return ret;
193
192
  } catch (e) {
194
- handlers.forEach((handler) => handler.error?.(e));
195
193
  const err = await context.useFilter(e, filter);
196
194
  if (res.sent)
197
195
  return;
@@ -1,5 +1,5 @@
1
1
  import { H3Event, Router } from 'h3';
2
- import { P, F as Factory } from '../../core-b8dcc009.js';
2
+ import { P, F as Factory } from '../../core-eb2a0799.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -76,7 +76,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
76
76
  if (!meta2)
77
77
  return resolve(await _chunkVUOACQPJjs.Context.filterRecord.default(new (0, _chunkVUOACQPJjs.BadRequestException)(`"${tag}" doesn't exist`)));
78
78
  const [name, method] = tag.split("-");
79
- const { paramsType, handlers, data: { params, guards, interceptors, filter } } = metaMap.get(tag);
79
+ const { paramsType, data: { params, guards, interceptors, filter } } = metaMap.get(tag);
80
80
  const instance = moduleMap.get(name);
81
81
  const contextData = {
82
82
  type: "h3",
@@ -114,7 +114,6 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
114
114
  const funcData = await moduleMap.get(name)[method](...args);
115
115
  resolve(await context.usePostInterceptor(funcData));
116
116
  } catch (e) {
117
- handlers.forEach((handler) => _optionalChain([handler, 'access', _2 => _2.error, 'optionalCall', _3 => _3(e)]));
118
117
  resolve(await context.useFilter(e, filter));
119
118
  }
120
119
  });
@@ -126,10 +125,10 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
126
125
  }));
127
126
  for (const i of meta) {
128
127
  const { method, http, header, tag } = i.data;
129
- if (!_optionalChain([http, 'optionalAccess', _4 => _4.type]))
128
+ if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
130
129
  continue;
131
130
  const methodTag = `${tag}-${method}`;
132
- const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
131
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
133
132
  const needBody = params.some((item) => item.type === "body");
134
133
  router[http.type](http.route, _h3.eventHandler.call(void 0, {
135
134
  onRequest: [
@@ -180,7 +179,6 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
180
179
  const ret = await context.usePostInterceptor(funcData);
181
180
  return ret;
182
181
  } catch (e) {
183
- handlers.forEach((handler) => _optionalChain([handler, 'access', _5 => _5.error, 'optionalCall', _6 => _6(e)]));
184
182
  const err = await context.useFilter(e, filter);
185
183
  _h3.setResponseStatus.call(void 0, event, err.status);
186
184
  return err;
@@ -193,7 +191,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
193
191
  handleMeta();
194
192
  createRoute();
195
193
  if (_chunkT4C6CCWMjs.IS_DEV) {
196
- _optionalChain([globalThis, 'access', _7 => _7.__PS_HMR__, 'optionalAccess', _8 => _8.push, 'call', _9 => _9(async () => {
194
+ _optionalChain([globalThis, 'access', _3 => _3.__PS_HMR__, 'optionalAccess', _4 => _4.push, 'call', _5 => _5(async () => {
197
195
  _chunkVUOACQPJjs.isAopDepInject.call(void 0, meta, {
198
196
  plugins,
199
197
  guards: globalGuards,
@@ -76,7 +76,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
76
76
  if (!meta2)
77
77
  return resolve(await Context.filterRecord.default(new BadRequestException(`"${tag}" doesn't exist`)));
78
78
  const [name, method] = tag.split("-");
79
- const { paramsType, handlers, data: { params, guards, interceptors, filter } } = metaMap.get(tag);
79
+ const { paramsType, data: { params, guards, interceptors, filter } } = metaMap.get(tag);
80
80
  const instance = moduleMap.get(name);
81
81
  const contextData = {
82
82
  type: "h3",
@@ -114,7 +114,6 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
114
114
  const funcData = await moduleMap.get(name)[method](...args);
115
115
  resolve(await context.usePostInterceptor(funcData));
116
116
  } catch (e) {
117
- handlers.forEach((handler) => handler.error?.(e));
118
117
  resolve(await context.useFilter(e, filter));
119
118
  }
120
119
  });
@@ -129,7 +128,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
129
128
  if (!http?.type)
130
129
  continue;
131
130
  const methodTag = `${tag}-${method}`;
132
- const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
131
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
133
132
  const needBody = params.some((item) => item.type === "body");
134
133
  router[http.type](http.route, eventHandler({
135
134
  onRequest: [
@@ -180,7 +179,6 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
180
179
  const ret = await context.usePostInterceptor(funcData);
181
180
  return ret;
182
181
  } catch (e) {
183
- handlers.forEach((handler) => handler.error?.(e));
184
182
  const err = await context.useFilter(e, filter);
185
183
  setResponseStatus(event, err.status);
186
184
  return err;
@@ -1,12 +1,13 @@
1
1
  import Router, { RouterParamContext } from '@koa/router';
2
2
  import { DefaultContext, DefaultState } from 'koa';
3
- import { P, F as Factory } from '../../core-b8dcc009.js';
3
+ import { P, F as Factory } from '../../core-eb2a0799.js';
4
4
  import 'phecda-core';
5
5
  import 'node:http';
6
6
 
7
7
  interface KoaCtx extends P.HttpContext {
8
8
  type: 'koa';
9
9
  ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>;
10
+ next: Function;
10
11
  }
11
12
  interface Options {
12
13
  route?: string;
@@ -52,7 +52,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
52
52
  ctx[_chunkT4C6CCWMjs.MODULE_SYMBOL] = moduleMap;
53
53
  ctx[_chunkT4C6CCWMjs.META_SYMBOL] = meta;
54
54
  await next();
55
- }, ..._chunkVUOACQPJjs.Context.usePlugin(plugins), async (ctx) => {
55
+ }, ..._chunkVUOACQPJjs.Context.usePlugin(plugins), async (ctx, next) => {
56
56
  const { body } = ctx.request;
57
57
  async function errorHandler(e) {
58
58
  const error = await _chunkVUOACQPJjs.Context.filterRecord.default(e);
@@ -70,7 +70,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
70
70
  if (!meta2)
71
71
  return resolve(await _chunkVUOACQPJjs.Context.filterRecord.default(new (0, _chunkVUOACQPJjs.BadRequestException)(`"${tag}" doesn't exist`)));
72
72
  const [name, method] = tag.split("-");
73
- const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
73
+ const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
74
74
  const instance = moduleMap.get(name);
75
75
  const contextData = {
76
76
  type: "koa",
@@ -79,6 +79,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
79
79
  meta: meta2,
80
80
  moduleMap,
81
81
  parallel: true,
82
+ next,
82
83
  ..._chunkCRAV4WSBjs.argToReq.call(void 0, params, item.args, ctx.headers),
83
84
  tag
84
85
  };
@@ -109,7 +110,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
109
110
  const funcData = await moduleMap.get(name)[method](...args);
110
111
  resolve(await context.usePostInterceptor(funcData));
111
112
  } catch (e) {
112
- handlers.forEach((handler) => _optionalChain([handler, 'access', _2 => _2.error, 'optionalCall', _3 => _3(e)]));
113
113
  resolve(await context.useFilter(e, filter));
114
114
  }
115
115
  });
@@ -122,15 +122,15 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
122
122
  });
123
123
  for (const i of meta) {
124
124
  const { method, http, header, tag } = i.data;
125
- if (!_optionalChain([http, 'optionalAccess', _4 => _4.type]))
125
+ if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
126
126
  continue;
127
127
  const methodTag = `${tag}-${method}`;
128
- const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
128
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
129
129
  app[http.type](http.route, async (ctx, next) => {
130
130
  ctx[_chunkT4C6CCWMjs.MODULE_SYMBOL] = moduleMap;
131
131
  ctx[_chunkT4C6CCWMjs.META_SYMBOL] = meta;
132
132
  await next();
133
- }, ..._chunkVUOACQPJjs.Context.usePlugin(plugins2), async (ctx) => {
133
+ }, ..._chunkVUOACQPJjs.Context.usePlugin(plugins2), async (ctx, next) => {
134
134
  const instance = moduleMap.get(tag);
135
135
  const contextData = {
136
136
  type: "koa",
@@ -142,7 +142,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
142
142
  query: ctx.query,
143
143
  params: ctx.params,
144
144
  body: ctx.request.body,
145
- headers: ctx.headers
145
+ headers: ctx.headers,
146
+ next
146
147
  };
147
148
  const context = new (0, _chunkVUOACQPJjs.Context)(contextData);
148
149
  try {
@@ -178,7 +179,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
178
179
  return;
179
180
  ctx.body = ret;
180
181
  } catch (e) {
181
- handlers.forEach((handler) => _optionalChain([handler, 'access', _5 => _5.error, 'optionalCall', _6 => _6(e)]));
182
182
  const err = await context.useFilter(e, filter);
183
183
  if (ctx.res.writableEnded)
184
184
  return;
@@ -192,7 +192,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
192
192
  handleMeta();
193
193
  createRoute();
194
194
  if (_chunkT4C6CCWMjs.IS_DEV) {
195
- _optionalChain([globalThis, 'access', _7 => _7.__PS_HMR__, 'optionalAccess', _8 => _8.push, 'call', _9 => _9(async () => {
195
+ _optionalChain([globalThis, 'access', _3 => _3.__PS_HMR__, 'optionalAccess', _4 => _4.push, 'call', _5 => _5(async () => {
196
196
  _chunkVUOACQPJjs.isAopDepInject.call(void 0, meta, {
197
197
  plugins,
198
198
  guards: globalGuards,
@@ -52,7 +52,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
52
52
  ctx[MODULE_SYMBOL] = moduleMap;
53
53
  ctx[META_SYMBOL] = meta;
54
54
  await next();
55
- }, ...Context.usePlugin(plugins), async (ctx) => {
55
+ }, ...Context.usePlugin(plugins), async (ctx, next) => {
56
56
  const { body } = ctx.request;
57
57
  async function errorHandler(e) {
58
58
  const error = await Context.filterRecord.default(e);
@@ -70,7 +70,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
70
70
  if (!meta2)
71
71
  return resolve(await Context.filterRecord.default(new BadRequestException(`"${tag}" doesn't exist`)));
72
72
  const [name, method] = tag.split("-");
73
- const { paramsType, handlers, data: { params, guards, interceptors, filter } } = meta2;
73
+ const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
74
74
  const instance = moduleMap.get(name);
75
75
  const contextData = {
76
76
  type: "koa",
@@ -79,6 +79,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
79
79
  meta: meta2,
80
80
  moduleMap,
81
81
  parallel: true,
82
+ next,
82
83
  ...argToReq(params, item.args, ctx.headers),
83
84
  tag
84
85
  };
@@ -109,7 +110,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
109
110
  const funcData = await moduleMap.get(name)[method](...args);
110
111
  resolve(await context.usePostInterceptor(funcData));
111
112
  } catch (e) {
112
- handlers.forEach((handler) => handler.error?.(e));
113
113
  resolve(await context.useFilter(e, filter));
114
114
  }
115
115
  });
@@ -125,12 +125,12 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
125
125
  if (!http?.type)
126
126
  continue;
127
127
  const methodTag = `${tag}-${method}`;
128
- const { paramsType, handlers, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
128
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
129
129
  app[http.type](http.route, async (ctx, next) => {
130
130
  ctx[MODULE_SYMBOL] = moduleMap;
131
131
  ctx[META_SYMBOL] = meta;
132
132
  await next();
133
- }, ...Context.usePlugin(plugins2), async (ctx) => {
133
+ }, ...Context.usePlugin(plugins2), async (ctx, next) => {
134
134
  const instance = moduleMap.get(tag);
135
135
  const contextData = {
136
136
  type: "koa",
@@ -142,7 +142,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
142
142
  query: ctx.query,
143
143
  params: ctx.params,
144
144
  body: ctx.request.body,
145
- headers: ctx.headers
145
+ headers: ctx.headers,
146
+ next
146
147
  };
147
148
  const context = new Context(contextData);
148
149
  try {
@@ -178,7 +179,6 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
178
179
  return;
179
180
  ctx.body = ret;
180
181
  } catch (e) {
181
- handlers.forEach((handler) => handler.error?.(e));
182
182
  const err = await context.useFilter(e, filter);
183
183
  if (ctx.res.writableEnded)
184
184
  return;
package/dist/test.d.ts CHANGED
@@ -2,7 +2,7 @@ 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, c as PickFunc } from './core-b8dcc009.js';
5
+ import { F as Factory, c as PickFunc } from './core-eb2a0799.js';
6
6
 
7
7
  declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
8
8
  get<C extends T[number]>(Module: C): InstanceType<C>;
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 _chunkRQOJIVQMjs = require('./chunk-RQOJIVQM.js');
3
+ var _chunkC37JSJDOjs = require('./chunk-C37JSJDO.js');
4
4
 
5
5
 
6
6
  var _chunkT4C6CCWMjs = require('./chunk-T4C6CCWM.js');
7
7
 
8
8
  // src/test.ts
9
9
  async function TestFactory(...Modules) {
10
- const { moduleMap, constructorMap } = await _chunkRQOJIVQMjs.Factory.call(void 0, Modules);
10
+ const { moduleMap, constructorMap } = await _chunkC37JSJDOjs.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;
package/dist/test.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Factory
3
- } from "./chunk-CPTMTSPU.mjs";
3
+ } from "./chunk-D26I5GHO.mjs";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-ONUMVNO7.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-server",
3
- "version": "5.0.0-alpha.16",
3
+ "version": "5.0.0-alpha.17",
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.10"
124
+ "phecda-core": "3.0.0-alpha.11"
125
125
  },
126
126
  "scripts": {
127
127
  "dev": "tsup --watch",