@basaltkit/express 1.0.0 → 1.2.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.
Files changed (3) hide show
  1. package/LICENSE +1 -1
  2. package/dist/index.js +15 -1
  3. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Machize Contributors
3
+ Copyright (c) 2026 Basalt Contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.js CHANGED
@@ -4,7 +4,11 @@ import {
4
4
  HttpServerCollector,
5
5
  HTTP_SERVER,
6
6
  runRoute,
7
- toErrorResponse
7
+ toErrorResponse,
8
+ isSseResponse,
9
+ sseProducerOf,
10
+ driveSse,
11
+ SSE_HEADERS
8
12
  } from "@basaltkit/http";
9
13
  import express from "express";
10
14
  var EXPRESS = createToken("express");
@@ -63,6 +67,15 @@ function basaltHandler(definition, container, enrichers, guards) {
63
67
  enrichers,
64
68
  guards
65
69
  });
70
+ if (isSseResponse(result)) {
71
+ res.writeHead(200, SSE_HEADERS);
72
+ await driveSse(sseProducerOf(result), {
73
+ write: (frame) => void res.write(frame),
74
+ end: () => res.end(),
75
+ onClose: (listener) => req.on("close", listener)
76
+ });
77
+ return;
78
+ }
66
79
  if (!reply.sent) reply.send(result);
67
80
  } catch (error) {
68
81
  const { status, body } = toErrorResponse(error);
@@ -84,6 +97,7 @@ function expressPlugin(options = {}) {
84
97
  container.singleton(EXPRESS, () => {
85
98
  const app = options.app ?? express();
86
99
  app.use(express.json());
100
+ app.use(express.urlencoded({ extended: false }));
87
101
  return app;
88
102
  });
89
103
  container.singleton(HTTP_SERVER, () => collector);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basaltkit/express",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Express adapter for Basalt: run the same typed routes, enrichers and guards on Express that you would on Fastify or Hono.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,8 +14,8 @@
14
14
  "dist"
15
15
  ],
16
16
  "dependencies": {
17
- "@basaltkit/core": "^1.0.0",
18
- "@basaltkit/http": "^1.0.0"
17
+ "@basaltkit/core": "^1.1.0",
18
+ "@basaltkit/http": "^1.7.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "express": "^4.19.0 || ^5.0.0"