From fb64b1b2eaee516a426ebd982fe80dc2eae471a6 Mon Sep 17 00:00:00 2001 From: Harvey Zuccon Date: Sun, 24 May 2026 16:45:29 +0200 Subject: [PATCH] Add index file. Add prepare script --- package.json | 5 +++-- src/index.ts | 5 +++++ src/sse-session.ts | 4 +++- src/utils/index.ts | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/utils/index.ts diff --git a/package.json b/package.json index 2ec4461..7f48d18 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { - "name": "ssesession", + "name": "sse-session", "version": "0.0.1", "description": "", "scripts": { "build": "tsc", "test": "vitest run", - "test:watch": "vitest" + "test:watch": "vitest", + "prepare": "npm run build" }, "files": [ "dist" diff --git a/src/index.ts b/src/index.ts index e69de29..c01861c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -0,0 +1,5 @@ +export * from "./types.js"; +export * from "./sse-session.js"; +export * from "./sse-event-parser.js"; + +export * from "./utils/index.js"; \ No newline at end of file diff --git a/src/sse-session.ts b/src/sse-session.ts index e1ef3f3..97a7f55 100644 --- a/src/sse-session.ts +++ b/src/sse-session.ts @@ -411,7 +411,9 @@ export class SSESession extends EventEmitter { const response = await this.options.fetch(this.url, requestOptions); if (!response.ok) { - throw new Error(`HTTP error! Status: ${response.status}`); + const responseCode = response.status; + const responseText = await response.text(); + throw new Error(`HTTP error! Status: ${responseCode} - ${responseText}`); } if (!response.body) { diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..73906da --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,4 @@ +export * from "./async-push-iterator.js"; +export * from "./exponential-backoff.js"; +export * from "./event-emitter.js"; +export * from "./misc.js"; \ No newline at end of file