@fy-tools/rpc-server-elysia 0.0.119-alpha.10384 → 0.0.119-alpha.10386

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.
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/lib/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,UAAU,CACrB,GAAG,SAAS,SAAS,GAAG,MAAM,EAC9B,MAAM,SAAS,aAAa,GAAG,aAAa;IAQzB,IAAI,EAAE,GAAG;IAAS,OAAO,EAAE,MAAM;IANpD;;;SAGK;IACE,CAAC,KAwBD,GAAG,8EAEM,CAAC,uBACD,SAAS,+CACT,WAAW,gDACX,QAAQ,8CACR,MAAM,2CACN,SAAS,+CACT,QAAQ,mMAhCf;gBAEU,IAAI,EAAE,GAAG,EAAS,OAAO,EAAE,MAAM;IAwDpD,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;CAI/C"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/lib/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,UAAU,CACrB,GAAG,SAAS,SAAS,GAAG,MAAM,EAC9B,MAAM,SAAS,aAAa,GAAG,aAAa;IAQzB,IAAI,EAAE,GAAG;IAAS,OAAO,EAAE,MAAM;IANpD;;;SAGK;IACE,CAAC,KA0BD,GAAG,8EAEM,CAAC,uBACD,SAAS,+CACT,WAAW,gDACX,QAAQ,8CACR,MAAM,2CACN,SAAS,+CACT,QAAQ,mMAlCf;gBAEU,IAAI,EAAE,GAAG,EAAS,OAAO,EAAE,MAAM;IA0DpD,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;CAI/C"}
@@ -15,15 +15,16 @@ class Controller {
15
15
  this._schema = _schema;
16
16
  const path = this._schema._basePath;
17
17
  const routes = {};
18
- this._app.group(path, (a) => {
19
- console.log('preparing controller ', this._app, this._schema);
18
+ const appGroup = this._app.group(path, (a) => {
19
+ let appGroup = a;
20
20
  for (const i in _schema._routes_map) {
21
21
  const route = new route_1.Route(a, this._schema._routes[_schema._routes_map[i]]);
22
- this._app = route._app;
22
+ appGroup = route._app;
23
23
  routes[i] = route;
24
24
  }
25
- return a;
25
+ return appGroup;
26
26
  });
27
+ this._app = appGroup;
27
28
  this.R = new Proxy(routes, {
28
29
  get(target, p, receiver) {
29
30
  return routes[p];
@@ -1,14 +1,12 @@
1
1
  import type { AnyRoute, Response } from '@fy-tools/rpc-server';
2
- import type { StandardSchemaV1 } from '@standard-schema/spec';
3
2
  import type { AnyElysia, Elysia } from 'elysia';
4
- import { InstanceFromRoute, RouteToContext } from './types';
3
+ import { RouteToContext } from './types';
5
4
  export declare class Route<App extends AnyElysia = Elysia, Schema extends AnyRoute = AnyRoute> {
6
5
  _app: App;
7
6
  _schema: Schema;
7
+ private _handlerFn;
8
8
  constructor(_app: App, _schema: Schema);
9
9
  build<T extends AnyElysia>(fn: (app: App) => T): Route<T, Schema>;
10
- handler<RouteContext extends RouteToContext<App, Schema>>(fn: (ctx: RouteContext) => Promise<Response<Schema>>, hook?: {
11
- response?: Record<Exclude<number, 200>, StandardSchemaV1>;
12
- }): InstanceFromRoute<App, Elysia<any, any, any, any, any, any, any>, Schema>;
10
+ handler<RouteContext extends RouteToContext<App, Schema>>(fn: (ctx: RouteContext) => Promise<Response<Schema>>): void;
13
11
  }
14
12
  //# sourceMappingURL=route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/lib/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAIR,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,qBAAa,KAAK,CAChB,GAAG,SAAS,SAAS,GAAG,MAAM,EAC9B,MAAM,SAAS,QAAQ,GAAG,QAAQ;IAEf,IAAI,EAAE,GAAG;IAAS,OAAO,EAAE,MAAM;gBAAjC,IAAI,EAAE,GAAG,EAAS,OAAO,EAAE,MAAM;IAEpD,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAK9C,OAAO,CAAC,YAAY,SAAS,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,EACtD,EAAE,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EACpD,IAAI,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,gBAAgB,CAAC,CAAA;KAAO,GAuBxD,iBAAiB,CAAC,GAAG,6CAAgB,MAAM,CAAC;CAE/D"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/lib/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAIR,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,KAAK,CAChB,GAAG,SAAS,SAAS,GAAG,MAAM,EAC9B,MAAM,SAAS,QAAQ,GAAG,QAAQ;IAMf,IAAI,EAAE,GAAG;IAAS,OAAO,EAAE,MAAM;IAJpD,OAAO,CAAC,UAAU,CAEhB;gBAEiB,IAAI,EAAE,GAAG,EAAS,OAAO,EAAE,MAAM;IAsBpD,KAAK,CAAC,CAAC,SAAS,SAAS,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAK9C,OAAO,CAAC,YAAY,SAAS,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,EACtD,EAAE,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CAIvD"}
package/dist/lib/route.js CHANGED
@@ -4,26 +4,28 @@ exports.Route = void 0;
4
4
  class Route {
5
5
  _app;
6
6
  _schema;
7
+ _handlerFn = () => {
8
+ throw new Error('Route handler not implemented');
9
+ };
7
10
  constructor(_app, _schema) {
8
11
  this._app = _app;
9
12
  this._schema = _schema;
10
- }
11
- build(fn) {
12
- const newApp = fn(this._app);
13
- return new Route(newApp, this._schema);
14
- }
15
- handler(fn, hook = {}) {
16
- console.log('preparing route ', this._app, this._schema);
17
13
  const response = this._schema._response;
18
14
  const routeSchema = {
19
- response: { 200: response, ...hook.response },
15
+ response: { 200: response },
20
16
  body: this._schema._body,
21
17
  params: this._schema._params,
22
18
  query: this._schema._query,
23
19
  };
24
- const route = this._app.route(this._schema._method.toUpperCase(), this._schema._path, fn, { ...hook, ...routeSchema });
20
+ const route = this._app.route(this._schema._method.toUpperCase(), this._schema._path, this._handlerFn, routeSchema);
25
21
  this._app = route;
26
- return route;
22
+ }
23
+ build(fn) {
24
+ const newApp = fn(this._app);
25
+ return new Route(newApp, this._schema);
26
+ }
27
+ handler(fn) {
28
+ this._handlerFn = fn;
27
29
  }
28
30
  }
29
31
  exports.Route = Route;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-tools/rpc-server-elysia",
3
- "version": "0.0.119-alpha.10384",
3
+ "version": "0.0.119-alpha.10386",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/festusyuma/fy-tools.git",
@@ -22,7 +22,7 @@
22
22
  "!**/*.tsbuildinfo"
23
23
  ],
24
24
  "dependencies": {
25
- "@fy-tools/rpc-server": "0.0.119-alpha.10384",
25
+ "@fy-tools/rpc-server": "0.0.119-alpha.10386",
26
26
  "elysia": "^1.4.29",
27
27
  "tslib": "^2.3.0",
28
28
  "@standard-schema/spec": "^1.0.0"