@adhd/apigen-plugin-api-fastify 0.1.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/README.md +20 -0
- package/index.d.ts +4 -0
- package/index.js +31696 -0
- package/index.mjs +400087 -0
- package/lib/generate.d.ts +5 -0
- package/lib/plugin.d.ts +4 -0
- package/lib/run.d.ts +3 -0
- package/lib/stream.d.ts +24 -0
- package/package.json +15 -0
package/lib/plugin.d.ts
ADDED
package/lib/run.d.ts
ADDED
package/lib/stream.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ApiStream } from '@adhd/apigen-runtime';
|
|
2
|
+
import { FastifyRequest, FastifyReply } from 'fastify';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Stream `apiStream` to the HTTP response as SSE.
|
|
6
|
+
*
|
|
7
|
+
* Sets `Content-Type: text/event-stream` and `Transfer-Encoding: chunked`.
|
|
8
|
+
* Each chunk is serialised as a `data: <JSON>\n\n` SSE frame.
|
|
9
|
+
*
|
|
10
|
+
* Error handling:
|
|
11
|
+
* - before first chunk: the reply status is set to the `ApiError` HTTP status
|
|
12
|
+
* (or 500) and the body is the `ApiError` JSON (normal §9 path).
|
|
13
|
+
* - after first chunk: a terminal `event: error\ndata: <JSON>\n\n` frame is
|
|
14
|
+
* flushed and the response is ended (Connect semantics).
|
|
15
|
+
*
|
|
16
|
+
* Cancellation: when the client disconnects (`req.raw` emits `'close'`), the
|
|
17
|
+
* in-flight stream is aborted via an internal `AbortController`. The stream
|
|
18
|
+
* terminates cleanly (end path — §11).
|
|
19
|
+
*
|
|
20
|
+
* @param stream - the `ApiStream` from the harness
|
|
21
|
+
* @param req - the Fastify request (used for client-disconnect detection)
|
|
22
|
+
* @param reply - the Fastify reply (raw `res` is used for direct writes)
|
|
23
|
+
*/
|
|
24
|
+
export declare function sendStreamSse(stream: ApiStream<unknown>, req: FastifyRequest, reply: FastifyReply): Promise<void>;
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adhd/apigen-plugin-api-fastify",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "./index.js",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@adhd/apigen-core": "^0.1.0",
|
|
7
|
+
"@adhd/apigen-runtime": "^0.1.0",
|
|
8
|
+
"fastify": "^4.0.0"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"module": "./index.mjs",
|
|
14
|
+
"types": "./index.d.ts"
|
|
15
|
+
}
|