pino-sse 1.0.1 → 1.0.3

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 (2) hide show
  1. package/package.json +4 -4
  2. package/psse.h3.ts +0 -46
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "pino-sse",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Pino transport for server side events",
5
5
  "license": "MIT",
6
6
  "author": "Jimmy Lew",
7
7
  "main": "./dist/psse.mjs",
8
8
  "scripts": {
9
- "lint": "eslint"
9
+ "build": "tsdown",
10
+ "lint": "eslint",
11
+ "prepack": "pnpm build"
10
12
  },
11
13
  "bin": {
12
14
  "pino-sse": "./psse.ts"
@@ -17,12 +19,10 @@
17
19
  ],
18
20
  "devDependencies": {
19
21
  "@antfu/eslint-config": "^6.7.3",
20
- "@types/node": "^25.0.3",
21
22
  "@types/uuid": "^11.0.0",
22
23
  "eslint": "^9.39.2"
23
24
  },
24
25
  "dependencies": {
25
- "h3": "^2.0.1-rc.6",
26
26
  "pino-abstract-transport": "^3.0.0",
27
27
  "tsdown": "^0.18.3",
28
28
  "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.56.0",
package/psse.h3.ts DELETED
@@ -1,46 +0,0 @@
1
- import build from 'pino-abstract-transport'
2
- import {createEventStream, defineEventHandler, H3, handleCors, serve } from 'h3'
3
- import { v4 as uuid } from 'uuid'
4
-
5
- interface SSETransportOptions {
6
-
7
- }
8
-
9
- export default async function (opts: SSETransportOptions) {
10
- const app = new H3()
11
- let event_stream: any = null
12
-
13
- app.get("/", (event) => {
14
- const cors = handleCors(event, {
15
- origin: '*',
16
- preflight: {
17
- statusCode: 204,
18
- },
19
- methods: '*',
20
- })
21
- if (cors !== false) return cors
22
-
23
- event_stream = createEventStream(event);
24
- return event_stream.send();
25
- });
26
-
27
- const server = serve(app, {port: 3333})
28
-
29
- return build(async (stream) => {
30
- for await (const obj of stream) {
31
- obj["log_id"] = uuid()
32
- const log = JSON.stringify(obj)
33
- if (!event_stream)
34
- continue
35
- await event_stream.push(log)
36
- }
37
- }, {
38
- async close(_) {
39
- console.log('Killing sse transport');
40
- await server.close()
41
- },
42
- parseLine(line) {
43
- return JSON.parse(line)
44
- },
45
- })
46
- }