@congruent-stack/congruent-api-express 0.7.0 → 0.9.0-rc.0

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
@@ -8,8 +8,11 @@ function createExpressRegistry(app, diContainer, apiContract) {
8
8
  const { genericPath } = entry.methodEndpoint;
9
9
  const method = entry.methodEndpoint.method.toLowerCase();
10
10
  app[method](genericPath, async (req, res) => {
11
+ if (!res.locals.diScope) {
12
+ res.locals.diScope = entry.dicontainer.createScope();
13
+ }
11
14
  req.pathParams = req.params;
12
- const result = await entry.trigger(req);
15
+ const result = await entry.trigger(res.locals.diScope, req);
13
16
  const resultHeaders = new Map(
14
17
  Object.entries(result.headers || {})
15
18
  );
@@ -18,8 +21,11 @@ function createExpressRegistry(app, diContainer, apiContract) {
18
21
  },
19
22
  middlewareHandlerRegisteredCallback: (entry) => {
20
23
  app.use(entry.genericPath, async (req, res, next) => {
24
+ if (!res.locals.diScope) {
25
+ res.locals.diScope = entry.dicontainer.createScope();
26
+ }
21
27
  req.pathParams = req.params;
22
- const haltResult = await entry.trigger(req, next);
28
+ const haltResult = await entry.trigger(res.locals.diScope, req, next);
23
29
  if (haltResult && congruentApi.isHttpResponseObject(haltResult)) {
24
30
  const haltResultHeaders = new Map(
25
31
  Object.entries(haltResult.headers || {})
package/dist/index.mjs CHANGED
@@ -6,8 +6,11 @@ function createExpressRegistry(app, diContainer, apiContract) {
6
6
  const { genericPath } = entry.methodEndpoint;
7
7
  const method = entry.methodEndpoint.method.toLowerCase();
8
8
  app[method](genericPath, async (req, res) => {
9
+ if (!res.locals.diScope) {
10
+ res.locals.diScope = entry.dicontainer.createScope();
11
+ }
9
12
  req.pathParams = req.params;
10
- const result = await entry.trigger(req);
13
+ const result = await entry.trigger(res.locals.diScope, req);
11
14
  const resultHeaders = new Map(
12
15
  Object.entries(result.headers || {})
13
16
  );
@@ -16,8 +19,11 @@ function createExpressRegistry(app, diContainer, apiContract) {
16
19
  },
17
20
  middlewareHandlerRegisteredCallback: (entry) => {
18
21
  app.use(entry.genericPath, async (req, res, next) => {
22
+ if (!res.locals.diScope) {
23
+ res.locals.diScope = entry.dicontainer.createScope();
24
+ }
19
25
  req.pathParams = req.params;
20
- const haltResult = await entry.trigger(req, next);
26
+ const haltResult = await entry.trigger(res.locals.diScope, req, next);
21
27
  if (haltResult && isHttpResponseObject(haltResult)) {
22
28
  const haltResultHeaders = new Map(
23
29
  Object.entries(haltResult.headers || {})
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.7.0",
4
+ "version": "0.9.0-rc.0",
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.7.0"
25
+ "@congruent-stack/congruent-api": "0.9.0-rc.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/express": "5.0.3",