@ldsg/route 0.3.8 → 0.3.10

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.
@@ -7,45 +7,46 @@ const application_1 = require("@ldsg/application");
7
7
  const handler_1 = require("@ldsg/handler");
8
8
  const supertest_1 = __importDefault(require("supertest"));
9
9
  const resource_1 = require("../resource");
10
- const handler = (req, res) => {
11
- res.send("Hello, World!");
10
+ const handler = (params) => {
11
+ const { res } = params;
12
+ res.send('Hello, World!');
12
13
  };
13
- test("application", async () => {
14
+ test('application', async () => {
14
15
  const applicationResource = new application_1.ApplicationResource({
15
- id: "application",
16
- kind: "application",
17
- parentId: "root",
16
+ id: 'application',
17
+ kind: 'application',
18
+ parentId: 'root',
18
19
  settings: {
19
- title: "应用",
20
- description: "应用根资源",
21
- name: "测试应用",
22
- },
20
+ title: '应用',
21
+ description: '应用根资源',
22
+ name: '测试应用'
23
+ }
23
24
  });
24
25
  new resource_1.RouteResource({
25
- id: "route",
26
- kind: "route",
27
- parentId: "application",
26
+ id: 'route',
27
+ kind: 'route',
28
+ parentId: 'application',
28
29
  settings: {
29
- title: "应用",
30
- description: "应用根资源",
31
- path: "/test",
32
- handlerResourceId: "route-test-app-test-handler",
33
- },
30
+ title: '应用',
31
+ description: '应用根资源',
32
+ path: '/test',
33
+ handlerResourceId: 'route-test-app-test-handler'
34
+ }
34
35
  });
35
36
  new handler_1.HandlerResource({
36
- id: "route-test-app-test-handler",
37
- kind: "handler",
38
- parentId: "root",
37
+ id: 'route-test-app-test-handler',
38
+ kind: 'handler',
39
+ parentId: 'root',
39
40
  settings: {
40
- title: "应用",
41
- description: "应用根资源",
42
- code: "",
41
+ title: '应用',
42
+ description: '应用根资源',
43
+ code: '',
43
44
  dependencies: [],
44
- handler,
45
- },
45
+ handler
46
+ }
46
47
  });
47
48
  const app = applicationResource.createExpressApp();
48
- const response = await (0, supertest_1.default)(app).get("/test");
49
+ const response = await (0, supertest_1.default)(app).get('/test');
49
50
  expect(response.statusCode).toBe(200);
50
- expect(response.text).toBe("Hello, World!");
51
+ expect(response.text).toBe('Hello, World!');
51
52
  });
@@ -1,6 +1,6 @@
1
- import { HandlerSpecificResourceSettings } from "@ldsg/handler";
2
- import { ResourceDefinitionSpecificResourceSettings } from "@ldsg/resource-definition";
3
- import { GeneralResourceSettings } from "@ldsg/types";
1
+ import { HandlerSpecificResourceSettings } from '@ldsg/handler';
2
+ import { ResourceDefinitionSpecificResourceSettings } from '@ldsg/resource-definition';
3
+ import { GeneralResourceSettings } from '@ldsg/types';
4
4
  /**
5
5
  * Instantiate Resource Handler General Resource Settings
6
6
  * 实例化资源处理程序普通资源配置
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAIlE,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBACtB,CAAC;AAEvC,eAAO,MAAM,8CAA8C,EAAE,0CAI1D,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,kDAAkD,EAAE,uBAI9D,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,mDAAmD,EAAE,+BAY/D,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAOrE,CAAC;AAEF,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAE5D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kDAAkD,EAAE,uBAGhE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mDAAmD,EAAE,+BAWjE,CAAC"}
package/dist/constants.js CHANGED
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_EXTENDED_HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.DEFAULT_EXTENDED_HANDLER_GENERAL_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
4
- const application_1 = require("@ldsg/application");
5
4
  /**
6
5
  * Instantiate Resource Handler General Resource Settings
7
6
  * 实例化资源处理程序普通资源配置
8
7
  */
9
8
  exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
10
- title: "路由实例化资源处理程序",
11
- description: "",
9
+ title: '路由实例化资源处理程序',
10
+ description: ''
12
11
  };
13
12
  /**
14
13
  * Instantiate Resource Handler Specific Resource Settings
@@ -19,22 +18,24 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
19
18
  code: `export * from "@ldsg/route";`,
20
19
  dependencies: [
21
20
  {
22
- name: "@ldsg/route",
23
- },
24
- ],
21
+ name: '@ldsg/route'
22
+ }
23
+ ]
24
+ };
25
+ exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
26
+ title: '路由资源定义',
27
+ description: ''
25
28
  };
26
- exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = { title: "路由资源定义", description: "" };
27
29
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
28
- kind: "route",
29
- parentKind: application_1.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS.kind,
30
+ kind: 'route'
30
31
  };
31
32
  /**
32
33
  * Default Extended Handler General Resource Settings
33
34
  * 默认扩展处理程序普通资源配置
34
35
  */
35
36
  exports.DEFAULT_EXTENDED_HANDLER_GENERAL_RESOURCE_SETTINGS = {
36
- title: "路由默认扩展处理程序",
37
- description: "",
37
+ title: '路由默认扩展处理程序',
38
+ description: ''
38
39
  };
39
40
  /**
40
41
  * Default Extended Handler Specific Resource Settings
@@ -48,7 +49,7 @@ const handler: RequestHandler = (req, res) => {
48
49
  };`,
49
50
  dependencies: [
50
51
  {
51
- name: "express",
52
- },
53
- ],
52
+ name: 'express'
53
+ }
54
+ ]
54
55
  };
package/dist/handler.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { Handler, HandlerExtendedResourceSettings } from "@ldsg/handler";
2
- import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
3
- import { RouteResource } from "./resource";
4
- import { RouteSpecificResourceSettings } from "./types";
5
- export declare const handler: Handler<[
6
- InstantiateResourceParams<HandlerExtendedResourceSettings<RouteSpecificResourceSettings>>
7
- ], InstantiateResourceRes<RouteResource>>;
1
+ import { Handler, HandlerExtendedResourceSettings } from '@ldsg/handler';
2
+ import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
3
+ import { RouteResource } from './resource';
4
+ import { RouteSpecificResourceSettings } from './types';
5
+ export declare const handler: Handler<InstantiateResourceParams<HandlerExtendedResourceSettings<RouteSpecificResourceSettings>>, InstantiateResourceRes<RouteResource>>;
8
6
  //# sourceMappingURL=handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B;IACE,yBAAyB,CACvB,+BAA+B,CAAC,6BAA6B,CAAC,CAC/D;CACF,EACD,sBAAsB,CAAC,aAAa,CAAC,CAChB,CAAC"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B,yBAAyB,CAAC,+BAA+B,CAAC,6BAA6B,CAAC,CAAC,EACzF,sBAAsB,CAAC,aAAa,CAAC,CAChB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./constants";
2
- export * from "./handler";
3
- export * from "./instantiate-resource";
4
- export * from "./resource";
5
- export * from "./types";
1
+ export * from './constants';
2
+ export * from './handler';
3
+ export * from './instantiate-resource';
4
+ export * from './resource';
5
+ export * from './types';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- import { HandlerExtendedResourceSettings } from "@ldsg/handler";
2
- import { InstantiateResource } from "@ldsg/resource";
3
- import { RouteResource } from "./resource";
4
- import { RouteSpecificResourceSettings } from "./types";
1
+ import { HandlerExtendedResourceSettings } from '@ldsg/handler';
2
+ import { InstantiateResource } from '@ldsg/resource';
3
+ import { RouteResource } from './resource';
4
+ import { RouteSpecificResourceSettings } from './types';
5
5
  export declare const instantiateResource: InstantiateResource<HandlerExtendedResourceSettings<RouteSpecificResourceSettings>, RouteResource>;
6
6
  //# sourceMappingURL=instantiate-resource.d.ts.map
@@ -6,7 +6,7 @@ const instantiateResource = (params) => {
6
6
  const { resourceConstructorParams } = params;
7
7
  const resource = new resource_1.RouteResource(resourceConstructorParams);
8
8
  const res = {
9
- resource,
9
+ resource
10
10
  };
11
11
  return res;
12
12
  };
@@ -1,6 +1,6 @@
1
- import { ExtendExpressApp } from "@ldsg/application";
2
- import { HandlerExtendedResource } from "@ldsg/handler";
3
- import { RouteSpecificResourceSettings } from "./types";
1
+ import { ExtendExpressApp } from '@ldsg/application';
2
+ import { HandlerExtendedResource } from '@ldsg/handler';
3
+ import { RouteSpecificResourceSettings } from './types';
4
4
  export declare class RouteResource extends HandlerExtendedResource<RouteSpecificResourceSettings> {
5
5
  extendExpressApp: ExtendExpressApp;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,qBAAa,aAAc,SAAQ,uBAAuB,CAAC,6BAA6B,CAAC;IACvF,gBAAgB,EAAE,gBAAgB,CAWhC;CACH"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,qBAAa,aAAc,SAAQ,uBAAuB,CAAC,6BAA6B,CAAC;IACvF,gBAAgB,EAAE,gBAAgB,CAchC;CACH"}
package/dist/resource.js CHANGED
@@ -7,9 +7,13 @@ class RouteResource extends handler_1.HandlerExtendedResource {
7
7
  super(...arguments);
8
8
  this.extendExpressApp = async (params) => {
9
9
  const { app } = params;
10
- const { settings: { path }, getExtendedHandler, } = this;
11
- const extendedHandler = getExtendedHandler();
12
- app.all(path, extendedHandler);
10
+ const { settings: { path }, executeExtendedHandler } = this;
11
+ app.all(path, async (req, res) => {
12
+ await executeExtendedHandler({
13
+ req,
14
+ res
15
+ });
16
+ });
13
17
  };
14
18
  }
15
19
  }
@@ -0,0 +1,9 @@
1
+ import { Handler, HandlerWithHandlerResourceInstance } from '@ldsg/handler';
2
+ interface RouteResourceExtendedHandlerParams {
3
+ req: any;
4
+ res: any;
5
+ }
6
+ export type RouteResourceExtendedHandler = Handler<RouteResourceExtendedHandlerParams, void>;
7
+ export type RouteResourceExtendedHandlerWithHandlerResourceInstance = HandlerWithHandlerResourceInstance<RouteResourceExtendedHandlerParams, void>;
8
+ export {};
9
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/types/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AAE5E,UAAU,kCAAkC;IAC1C,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,CAAC;CACV;AAED,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC;AAE7F,MAAM,MAAM,uDAAuD,GAAG,kCAAkC,CACtG,kCAAkC,EAClC,IAAI,CACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,3 @@
1
- export * from "./specific-resource-settings";
1
+ export * from './resource-extended-handler';
2
+ export * from './specific-resource-settings';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC"}
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./resource-extended-handler"), exports);
17
18
  __exportStar(require("./specific-resource-settings"), exports);
@@ -0,0 +1,8 @@
1
+ import { ResourceExtendedHandler } from '@ldsg/handler';
2
+ interface RouteResourceExtendedHandlerParams {
3
+ req: any;
4
+ res: any;
5
+ }
6
+ export type RouteResourceExtendedHandler = ResourceExtendedHandler<RouteResourceExtendedHandlerParams, void>;
7
+ export {};
8
+ //# sourceMappingURL=resource-extended-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-extended-handler.d.ts","sourceRoot":"","sources":["../../src/types/resource-extended-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,UAAU,kCAAkC;IAC1C,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,CAAC;CACV;AAED,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { SpecificResourceSettings } from "@ldsg/types";
1
+ import { SpecificResourceSettings } from '@ldsg/types';
2
2
  export interface RouteSpecificResourceSettings extends SpecificResourceSettings {
3
3
  /**
4
4
  * Route Path
@@ -1 +1 @@
1
- {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,6BACf,SAAQ,wBAAwB;IAChC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
1
+ {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,6BAA8B,SAAQ,wBAAwB;IAC7E;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd"}
package/package.json CHANGED
@@ -1,30 +1,35 @@
1
1
  {
2
2
  "name": "@ldsg/route",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "description": "",
5
+ "keywords": [],
6
+ "license": "MIT",
7
+ "author": "wanxger",
5
8
  "main": "dist/index.js",
9
+ "types": "dist",
6
10
  "files": [
7
11
  "dist/"
8
12
  ],
9
- "types": "dist",
10
- "keywords": [],
11
- "author": "wanxger",
12
- "license": "MIT",
13
- "publishConfig": {
14
- "access": "public"
15
- },
16
13
  "dependencies": {
17
- "@ldsg/resource": "0.3.8",
18
- "@ldsg/handler": "0.3.8",
19
- "@ldsg/resource-definition": "0.3.8"
14
+ "@ldsg/handler": "0.3.10",
15
+ "@ldsg/resource": "0.3.10",
16
+ "@ldsg/resource-definition": "0.3.10"
20
17
  },
21
18
  "devDependencies": {
22
19
  "@types/express": "^5.0.1",
20
+ "@types/jest": "^29.5.2",
23
21
  "@types/supertest": "^6.0.0",
24
- "supertest": "^6.3.4",
25
22
  "express": "^5.1.0",
26
- "@ldsg/application": "0.3.8",
27
- "@ldsg/types": "0.3.8"
23
+ "jest": "^29.5.0",
24
+ "supertest": "^6.3.4",
25
+ "ts-jest": "^29.1.5",
26
+ "ts-node": "^10.9.2",
27
+ "typescript": "^5.8.3",
28
+ "@ldsg/application": "0.3.10",
29
+ "@ldsg/types": "0.3.10"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
28
33
  },
29
34
  "scripts": {
30
35
  "build": "tsc --project tsconfig.build.json",