@nwire/express 0.12.1 → 0.13.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.
@@ -44,6 +44,10 @@ export function expressAdapter(config = {}) {
44
44
  app() {
45
45
  return appInstance;
46
46
  },
47
+ handler() {
48
+ // An Express application IS a `(req, res)` handler — mountable as-is.
49
+ return appInstance;
50
+ },
47
51
  async boot(ctx) {
48
52
  const expressApp = express();
49
53
  appInstance = expressApp;
@@ -94,16 +98,23 @@ export function expressAdapter(config = {}) {
94
98
  };
95
99
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
100
  const wireApp = wire.app;
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- const runtimeExecute = wireApp?.runtime?.execute;
99
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
- const hasRunMethod = typeof wire.handler?.run === "function";
101
+ const runtime = wireApp?.runtime;
101
102
  let result;
102
103
  try {
103
- if (runtimeExecute && hasRunMethod) {
104
- result = await runtimeExecute.call(wireApp.runtime, wire.handler, input, envelopePartial);
104
+ if (runtime?.receive) {
105
+ // Unified inbound the HTTP request becomes a command on the
106
+ // runtime's source chain (the same path http-koa uses). The
107
+ // terminal router lands it on runtime.execute, which builds the
108
+ // canonical ctx and threads transport extras (logger, req, res).
109
+ result = await runtime.receive({
110
+ kind: "command",
111
+ name: wire.handler?.name ?? "handler",
112
+ input,
113
+ target: wire.handler,
114
+ }, { envelope: envelopePartial, extras: { logger, req, res } });
105
115
  }
106
116
  else {
117
+ // No-runtime fallback — standalone interface without an App.
107
118
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
119
  const fn = wire.handler.run ?? wire.handler;
109
120
  const handlerCtx = {
@@ -246,14 +257,17 @@ export function nwireToExpressRouter(app, options = {}) {
246
257
  const reqContainer = app.container.createScope();
247
258
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
248
259
  const wireApp = wire.app ?? app;
249
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
250
- const runtimeExecute = wireApp?.runtime?.execute;
251
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
252
- const hasRunMethod = typeof wire.handler?.run === "function";
260
+ const runtime = wireApp?.runtime;
253
261
  try {
254
262
  let result;
255
- if (runtimeExecute && hasRunMethod) {
256
- result = await runtimeExecute.call(wireApp.runtime, wire.handler, input, {});
263
+ if (runtime?.receive) {
264
+ // Unified inbound — command on the runtime's source chain.
265
+ result = await runtime.receive({
266
+ kind: "command",
267
+ name: wire.handler?.name ?? "handler",
268
+ input,
269
+ target: wire.handler,
270
+ }, { extras: { logger, req, res } });
257
271
  }
258
272
  else {
259
273
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwire/express",
3
- "version": "0.12.1",
3
+ "version": "0.13.1",
4
4
  "description": "Nwire — Express-backed HTTP adopter. expressAdapter() consumes wires with binding.$adapter==='http' and mounts them on an Express server; fromExpressMiddleware() bridges Express middleware into httpKoa's middleware chain.",
5
5
  "keywords": [
6
6
  "adopter",
@@ -29,10 +29,10 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "express": "^5.1.0",
32
- "@nwire/container": "0.12.1",
33
- "@nwire/endpoint": "0.12.1",
34
- "@nwire/logger": "0.12.1",
35
- "@nwire/wires": "0.12.1"
32
+ "@nwire/endpoint": "0.13.1",
33
+ "@nwire/wires": "0.13.1",
34
+ "@nwire/logger": "0.13.1",
35
+ "@nwire/container": "0.13.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/express": "^5.0.0",
@@ -42,7 +42,7 @@
42
42
  "typescript": "^5.9.3",
43
43
  "vitest": "^4.0.18",
44
44
  "zod": "^4.0.0",
45
- "@nwire/app": "0.12.1"
45
+ "@nwire/app": "0.13.1"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "express": "^4.0.0 || ^5.0.0"