@congruent-stack/congruent-api-express 0.11.4 → 0.12.1

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/index.cjs CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  var congruentApi = require('@congruent-stack/congruent-api');
4
4
 
5
+ function adapt(params) {
6
+ params.apiContract.createRegistry = function() {
7
+ return createExpressRegistry(
8
+ params.expressApp,
9
+ params.diContainer,
10
+ this
11
+ // 'this' is the ApiContract instance (params.apiContract)
12
+ );
13
+ };
14
+ }
5
15
  function createExpressRegistry(app, diContainer, apiContract) {
6
16
  const registry = congruentApi.createRegistry(diContainer, apiContract, {
7
17
  handlerRegisteredCallback: (entry) => {
@@ -115,5 +125,6 @@ function expressPreHandler(app, prehandler) {
115
125
  });
116
126
  }
117
127
 
128
+ exports.adapt = adapt;
118
129
  exports.createExpressRegistry = createExpressRegistry;
119
130
  exports.expressPreHandler = expressPreHandler;
package/dist/index.d.cts CHANGED
@@ -2,7 +2,12 @@ import * as _congruent_stack_congruent_api from '@congruent-stack/congruent-api'
2
2
  import { IApiContractDefinition, ValidateApiContractDefinition, DIContainer, ApiContract, IHttpMethodEndpointDefinition, ValidateHttpMethodEndpointDefinition, PrepareRegistryEntryCallback } from '@congruent-stack/congruent-api';
3
3
  import { Express, RequestHandler } from 'express';
4
4
 
5
+ declare function adapt(params: {
6
+ expressApp: Express;
7
+ diContainer: any;
8
+ apiContract: any;
9
+ }): void;
5
10
  declare function createExpressRegistry<TDef extends IApiContractDefinition & ValidateApiContractDefinition<TDef>, TDIContainer extends DIContainer>(app: Express, diContainer: TDIContainer, apiContract: ApiContract<TDef>): _congruent_stack_congruent_api.ApiHandlersRegistry<TDef, TDIContainer, "">;
6
11
  declare function expressPreHandler<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string>(app: Express, prehandler: RequestHandler): PrepareRegistryEntryCallback<TDef, TDIContainer, TPathParams>;
7
12
 
8
- export { createExpressRegistry, expressPreHandler };
13
+ export { adapt, createExpressRegistry, expressPreHandler };
package/dist/index.d.mts CHANGED
@@ -2,7 +2,12 @@ import * as _congruent_stack_congruent_api from '@congruent-stack/congruent-api'
2
2
  import { IApiContractDefinition, ValidateApiContractDefinition, DIContainer, ApiContract, IHttpMethodEndpointDefinition, ValidateHttpMethodEndpointDefinition, PrepareRegistryEntryCallback } from '@congruent-stack/congruent-api';
3
3
  import { Express, RequestHandler } from 'express';
4
4
 
5
+ declare function adapt(params: {
6
+ expressApp: Express;
7
+ diContainer: any;
8
+ apiContract: any;
9
+ }): void;
5
10
  declare function createExpressRegistry<TDef extends IApiContractDefinition & ValidateApiContractDefinition<TDef>, TDIContainer extends DIContainer>(app: Express, diContainer: TDIContainer, apiContract: ApiContract<TDef>): _congruent_stack_congruent_api.ApiHandlersRegistry<TDef, TDIContainer, "">;
6
11
  declare function expressPreHandler<TDef extends IHttpMethodEndpointDefinition & ValidateHttpMethodEndpointDefinition<TDef>, TDIContainer extends DIContainer, TPathParams extends string>(app: Express, prehandler: RequestHandler): PrepareRegistryEntryCallback<TDef, TDIContainer, TPathParams>;
7
12
 
8
- export { createExpressRegistry, expressPreHandler };
13
+ export { adapt, createExpressRegistry, expressPreHandler };
package/dist/index.mjs CHANGED
@@ -1,5 +1,15 @@
1
1
  import { createRegistry, triggerMiddlewareDecoratorNoStaticTypeCheck, isHttpResponseObject, triggerEndpointDecoratorNoStaticTypeCheck } from '@congruent-stack/congruent-api';
2
2
 
3
+ function adapt(params) {
4
+ params.apiContract.createRegistry = function() {
5
+ return createExpressRegistry(
6
+ params.expressApp,
7
+ params.diContainer,
8
+ this
9
+ // 'this' is the ApiContract instance (params.apiContract)
10
+ );
11
+ };
12
+ }
3
13
  function createExpressRegistry(app, diContainer, apiContract) {
4
14
  const registry = createRegistry(diContainer, apiContract, {
5
15
  handlerRegisteredCallback: (entry) => {
@@ -113,4 +123,4 @@ function expressPreHandler(app, prehandler) {
113
123
  });
114
124
  }
115
125
 
116
- export { createExpressRegistry, expressPreHandler };
126
+ export { adapt, createExpressRegistry, expressPreHandler };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@congruent-stack/congruent-api-express",
3
3
  "type": "module",
4
- "version": "0.11.4",
4
+ "version": "0.12.1",
5
5
  "description": "Typescript schema-first tooling for agnostic REST APIs.",
6
6
  "keywords": [],
7
7
  "author": "congruent-stack",
@@ -22,7 +22,7 @@
22
22
  "peerDependencies": {
23
23
  "@types/express": "5.0.3",
24
24
  "express": "5.1.0",
25
- "@congruent-stack/congruent-api": "0.11.4"
25
+ "@congruent-stack/congruent-api": "0.12.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/express": "5.0.3",