@shivaedev/http 0.2.0 → 0.3.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ ## 0.3.1 - 2026-10-31
4
+
5
+ ### Fixed
6
+
7
+ - Include `CHANGELOG.md` in published package contents so release notes are available in `node_modules`.
8
+ - Release checks reject published package `files` lists that omit `CHANGELOG.md`, naming the package and how to include it.
9
+ - `RemoteHttpError` carries a readable message naming the status, method, host and path without query strings, headers or bodies.
10
+ - Failed jobs record the error message or a summary of its fields with sensitive values redacted, beside the error tag.
11
+
12
+ ## 0.3.0 - 2026-10-30
13
+
14
+ ### Breaking
15
+
16
+ - Request body reads fail with HTTP 413 before reading when Effect's `HttpIncomingMessage.MaxBodySize` is undefined. Provide a finite byte limit through `Effect.provideService(HttpIncomingMessage.MaxBodySize, ByteSize.bytes(limit))` when mounting native routes or webhook routes outside `appHost`.
17
+ - `RequestBodyTooLarge` is a Schema tagged error carrying a numeric `limit` in bytes, with `0` for an unconfigured limit. Replace bigint comparisons with number comparisons and obtain request context separately; the error no longer carries `request` or its headers.
18
+
19
+ ## 0.2.0 - 2026-10-30
20
+
21
+ ### Changed
22
+
23
+ - Require the Effect 4.0.6 stack.
24
+
25
+ ### Fixed
26
+
27
+ - Publish committed SQL invalidations immediately for their owning database, including when another database has an open transaction.
28
+
29
+ ### Breaking
30
+
31
+ - `@shivaedev/sql`: migration-body SQL failures now propagate as native typed `MigrationError` failures. Handle them with `Effect.catchTag("MigrationError", ...)` instead of defect recovery; migration-body defects remain defects.
32
+ - `@shivaedev/http`: bounded request-body reads use the native reader and its connection cleanup. Do not assume a rejected upload can drain an arbitrarily large unread body and reuse its connection; allow the HTTP client to open a new connection. The optional Node platform peer is no longer required by this package.
33
+
34
+ ## 0.1.1 - 2026-10-29
35
+
36
+ ### Fixed
37
+
38
+ - The application host constructs services, handlers and routes before listening, so startup connections are refused until requests can be answered.
39
+ - Server and HTTP modules import Node platform modules directly to avoid loading Redis during startup.
40
+ - Generated apps import Node platform modules directly, and deployment stories allow enough time for their sequential cold processes without a fixed timeout on each startup health probe.
41
+
42
+ ## 0.1.0 - 2026-10-27
43
+
44
+ ### Added
45
+
46
+ - First release of `@shivaedev/http`: typed status failures (`filterStatus.ts`, `errors.ts`), link pagination (`paginate.ts`) and bounded response bodies (`body.ts`) for Effect's HTTP client, and bounded request bodies for native Node routes (`server/boundedBody.ts`).
package/README.md CHANGED
@@ -56,7 +56,7 @@ const routes = HttpRouter.add("POST", "/webhook", (request) =>
56
56
  );
57
57
  ```
58
58
 
59
- Oversized `content-length` headers are rejected before reading. Native Effect owns body collection and connection cleanup after chunked overflow; connection reuse depends on its unread-body drain limit. `RequestBodyTooLarge` is a typed failure that implements Effect's `HttpServerRespondable` protocol with status 413. Consume the body once through this reader and decode the result in the application.
59
+ Oversized `content-length` headers are rejected before reading. If `MaxBodySize` is undefined, the reader refuses before reading with `RequestBodyTooLarge` and `limit: 0`, including on routes mounted outside `appHost`. Native Effect owns body collection and connection cleanup after chunked overflow; connection reuse depends on its unread-body drain limit. `RequestBodyTooLarge` is a Schema tagged error with the string tag `"RequestBodyTooLarge"` and a numeric byte `limit`, without the request or its credentials. It implements Effect's `HttpServerRespondable` protocol with status 413. Consume the body once through this reader and decode the result in the application.
60
60
 
61
61
  ### Install and limits
62
62
 
package/dist/errors.d.ts CHANGED
@@ -34,6 +34,7 @@ declare const RemoteHttpError_base: Schema.Class<RemoteHttpError, Schema.TaggedS
34
34
  url: Schema.String;
35
35
  }>, import("effect/Cause").YieldableError>;
36
36
  export declare class RemoteHttpError extends RemoteHttpError_base {
37
+ get message(): string;
37
38
  }
38
39
  export type RemoteStatusError = RemoteUnauthorized | RemoteNotFound | RemoteGone | RemoteRateLimited | RemoteHttpError;
39
40
  declare const PaginationLinkError_base: Schema.Class<PaginationLinkError, Schema.TaggedStruct<"PaginationLinkError", {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;AAIhC,qBAAa,kBAAmB,SAAQ,uBAAsE;CAAG;;;;;;AACjH,qBAAa,cAAe,SAAQ,mBAA8D;CAAG;;;;;;AACrG,qBAAa,UAAW,SAAQ,eAAsD;CAAG;;;;;;;AACzF,qBAAa,iBAAkB,SAAQ,sBAGrC;CAAG;;;;;;AACL,qBAAa,eAAgB,SAAQ,oBAAgE;CAAG;AAExG,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,cAAc,GAAG,UAAU,GAAG,iBAAiB,GAAG,eAAe,CAAC;;;;;AAEvH,qBAAa,mBAAoB,SAAQ,wBAGvC;CAAG;;;;AAEL,qBAAa,oBAAqB,SAAQ,yBAExC;CAAG"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;AAIhC,qBAAa,kBAAmB,SAAQ,uBAAsE;CAAG;;;;;;AACjH,qBAAa,cAAe,SAAQ,mBAA8D;CAAG;;;;;;AACrG,qBAAa,UAAW,SAAQ,eAAsD;CAAG;;;;;;;AACzF,qBAAa,iBAAkB,SAAQ,sBAGrC;CAAG;;;;;;AACL,qBAAa,eAAgB,SAAQ,oBAAgE;IACpG,IAAa,OAAO,IAAI,MAAM,CAG7B;CACD;AAED,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG,cAAc,GAAG,UAAU,GAAG,iBAAiB,GAAG,eAAe,CAAC;;;;;AAEvH,qBAAa,mBAAoB,SAAQ,wBAGvC;CAAG;;;;AAEL,qBAAa,oBAAqB,SAAQ,yBAExC;CAAG"}
package/dist/errors.js CHANGED
@@ -12,6 +12,10 @@ export class RemoteRateLimited extends Schema.TaggedError()("RemoteRateLimited",
12
12
  }) {
13
13
  }
14
14
  export class RemoteHttpError extends Schema.TaggedError()("RemoteHttpError", answer) {
15
+ get message() {
16
+ const url = new URL(this.url);
17
+ return `HTTP ${this.status}: ${this.method} ${url.host}${url.pathname}`;
18
+ }
15
19
  }
16
20
  export class PaginationLinkError extends Schema.TaggedError()("PaginationLinkError", {
17
21
  reason: Schema.Literals(["cross-origin", "invalid"]),
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;AAEpF,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,WAAW,EAAsB,CAAC,oBAAoB,EAAE,MAAM,CAAC;CAAG;AACjH,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,WAAW,EAAkB,CAAC,gBAAgB,EAAE,MAAM,CAAC;CAAG;AACrG,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,WAAW,EAAc,CAAC,YAAY,EAAE,MAAM,CAAC;CAAG;AACzF,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,WAAW,EAAqB,CAAC,mBAAmB,EAAE;IACnG,GAAG,MAAM;IACT,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC;CAClD,CAAC;CAAG;AACL,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,EAAmB,CAAC,iBAAiB,EAAE,MAAM,CAAC;CAAG;AAIxG,MAAM,OAAO,mBAAoB,SAAQ,MAAM,CAAC,WAAW,EAAuB,CAAC,qBAAqB,EAAE;IACzG,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;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ACD;AAID,MAAM,OAAO,mBAAoB,SAAQ,MAAM,CAAC,WAAW,EAAuB,CAAC,qBAAqB,EAAE;IACzG,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACpD,GAAG,EAAE,MAAM,CAAC,MAAM;CAClB,CAAC;CAAG;AAEL,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,EAAwB,CAAC,sBAAsB,EAAE;IAC5G,KAAK,EAAE,MAAM,CAAC,MAAM;CACpB,CAAC;CAAG"}
@@ -1,12 +1,9 @@
1
- import { Effect } from "effect";
1
+ import { Effect, Schema } from "effect";
2
2
  import { type HttpServerRequest, HttpServerRespondable, HttpServerResponse } from "effect/http";
3
- declare const RequestBodyTooLarge_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
4
- readonly _tag: "RequestBodyTooLarge";
5
- } & Readonly<A>;
6
- export declare class RequestBodyTooLarge extends RequestBodyTooLarge_base<{
7
- readonly request: HttpServerRequest.HttpServerRequest;
8
- readonly limit: bigint;
9
- }> implements HttpServerRespondable.Respondable {
3
+ declare const RequestBodyTooLarge_base: Schema.Class<RequestBodyTooLarge, Schema.TaggedStruct<"RequestBodyTooLarge", {
4
+ readonly limit: Schema.Number;
5
+ }>, import("effect/Cause").YieldableError>;
6
+ export declare class RequestBodyTooLarge extends RequestBodyTooLarge_base implements HttpServerRespondable.Respondable {
10
7
  [HttpServerRespondable.symbol](): Effect.Effect<HttpServerResponse.HttpServerResponse, never, never>;
11
8
  }
12
9
  export declare const readBoundedBody: (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<ArrayBuffer, import("effect/http/HttpServerError").HttpServerError | RequestBodyTooLarge, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"boundedBody.d.ts","sourceRoot":"","sources":["../../src/server/boundedBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAuB,KAAK,iBAAiB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;;;;AAGrH,qBAAa,mBACZ,SAAQ,yBAAwC;IAC/C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,CAAC;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB,CACD,YAAW,qBAAqB,CAAC,WAAW;IAE5C,CAAC,qBAAqB,CAAC,MAAM,CAAC,uEAE7B;CACD;AAED,eAAO,MAAM,eAAe,kKAe1B,CAAC"}
1
+ {"version":3,"file":"boundedBody.d.ts","sourceRoot":"","sources":["../../src/server/boundedBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAuB,KAAK,iBAAiB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;;;;AAGrH,qBAAa,mBACZ,SAAQ,wBACR,YAAW,qBAAqB,CAAC,WAAW;IAE5C,CAAC,qBAAqB,CAAC,MAAM,CAAC,uEAE7B;CACD;AAED,eAAO,MAAM,eAAe,kKAgB1B,CAAC"}
@@ -1,20 +1,21 @@
1
- import { Data, Effect } from "effect";
1
+ import { Effect, Schema } from "effect";
2
2
  import { HttpIncomingMessage, HttpServerRespondable, HttpServerResponse } from "effect/http";
3
3
  import * as HttpStatus from "effect/http/HttpStatus";
4
- export class RequestBodyTooLarge extends Data.TaggedError("RequestBodyTooLarge") {
4
+ export class RequestBodyTooLarge extends Schema.TaggedError()("RequestBodyTooLarge", { limit: Schema.Number }) {
5
5
  [HttpServerRespondable.symbol]() {
6
6
  return Effect.succeed(HttpServerResponse.empty({ status: HttpStatus.fromLiteral("PayloadTooLarge") }));
7
7
  }
8
8
  }
9
9
  export const readBoundedBody = Effect.fnUntraced(function* (request) {
10
- const limit = yield* HttpIncomingMessage.MaxBodySize;
11
- if (limit === undefined) {
12
- return yield* request.arrayBuffer;
10
+ const maxBodySize = yield* HttpIncomingMessage.MaxBodySize;
11
+ if (maxBodySize === undefined) {
12
+ return yield* new RequestBodyTooLarge({ limit: 0 });
13
13
  }
14
+ const limit = Number(maxBodySize);
14
15
  const length = request.headers["content-length"];
15
- if (length !== undefined && BigInt(length) > limit) {
16
- return yield* new RequestBodyTooLarge({ limit, request });
16
+ if (length !== undefined && BigInt(length) > maxBodySize) {
17
+ return yield* new RequestBodyTooLarge({ limit });
17
18
  }
18
- return yield* request.arrayBuffer.pipe(Effect.catchIf((error) => error.reason._tag === "RequestParseError" && error.reason.reason === "BodyTooLarge", () => new RequestBodyTooLarge({ limit, request })));
19
+ return yield* request.arrayBuffer.pipe(Effect.catchIf((error) => error.reason._tag === "RequestParseError" && error.reason.reason === "BodyTooLarge", () => new RequestBodyTooLarge({ limit })));
19
20
  });
20
21
  //# sourceMappingURL=boundedBody.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"boundedBody.js","sourceRoot":"","sources":["../../src/server/boundedBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAA0B,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACrH,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAErD,MAAM,OAAO,mBACZ,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAG5C;IAGF,CAAC,qBAAqB,CAAC,MAAM,CAAC;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;IACxG,CAAC;CACD;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CA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CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;IACxG,CAAC;CACD;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,OAA4C;IACvG,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC;IAC3D,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC,CAAC,IAAI,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjD,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,WAAW,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAC,CAAC,IAAI,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CACrC,MAAM,CAAC,OAAO,CACb,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,mBAAmB,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,cAAc,EAC9F,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,CACxC,CACD,CAAC;AACH,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/http",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Bounded HTTP bodies, status failures and paginated clients over Effect HTTP",
5
5
  "keywords": [
6
6
  "effect"
@@ -41,12 +41,13 @@
41
41
  "!src/**/*.spec.ts",
42
42
  "!src/**/*.spec.tsx",
43
43
  "!src/**/test-support",
44
+ "CHANGELOG.md",
44
45
  "README.md"
45
46
  ],
46
47
  "devDependencies": {
47
48
  "@effect/platform-node": "4.0.6",
48
- "@shivaedev/quality": "0.45.0",
49
- "@shivaedev/test-story": "0.24.0",
49
+ "@shivaedev/quality": "0.48.1",
50
+ "@shivaedev/test-story": "0.27.0",
50
51
  "@types/node": "24.19.2",
51
52
  "effect": "4.0.6",
52
53
  "typescript": "7.0.2",
package/src/errors.ts CHANGED
@@ -9,7 +9,12 @@ export class RemoteRateLimited extends Schema.TaggedError<RemoteRateLimited>()("
9
9
  ...answer,
10
10
  retryAfter: Schema.optionalKey(Schema.DateTimeUtc),
11
11
  }) {}
12
- export class RemoteHttpError extends Schema.TaggedError<RemoteHttpError>()("RemoteHttpError", answer) {}
12
+ export class RemoteHttpError extends Schema.TaggedError<RemoteHttpError>()("RemoteHttpError", answer) {
13
+ override get message(): string {
14
+ const url = new URL(this.url);
15
+ return `HTTP ${this.status}: ${this.method} ${url.host}${url.pathname}`;
16
+ }
17
+ }
13
18
 
14
19
  export type RemoteStatusError = RemoteUnauthorized | RemoteNotFound | RemoteGone | RemoteRateLimited | RemoteHttpError;
15
20
 
@@ -1,12 +1,9 @@
1
- import { Data, Effect } from "effect";
1
+ import { Effect, Schema } from "effect";
2
2
  import { HttpIncomingMessage, type HttpServerRequest, HttpServerRespondable, HttpServerResponse } from "effect/http";
3
3
  import * as HttpStatus from "effect/http/HttpStatus";
4
4
 
5
5
  export class RequestBodyTooLarge
6
- extends Data.TaggedError("RequestBodyTooLarge")<{
7
- readonly request: HttpServerRequest.HttpServerRequest;
8
- readonly limit: bigint;
9
- }>
6
+ extends Schema.TaggedError<RequestBodyTooLarge>()("RequestBodyTooLarge", { limit: Schema.Number })
10
7
  implements HttpServerRespondable.Respondable
11
8
  {
12
9
  [HttpServerRespondable.symbol]() {
@@ -15,18 +12,19 @@ export class RequestBodyTooLarge
15
12
  }
16
13
 
17
14
  export const readBoundedBody = Effect.fnUntraced(function* (request: HttpServerRequest.HttpServerRequest) {
18
- const limit = yield* HttpIncomingMessage.MaxBodySize;
19
- if (limit === undefined) {
20
- return yield* request.arrayBuffer;
15
+ const maxBodySize = yield* HttpIncomingMessage.MaxBodySize;
16
+ if (maxBodySize === undefined) {
17
+ return yield* new RequestBodyTooLarge({ limit: 0 });
21
18
  }
19
+ const limit = Number(maxBodySize);
22
20
  const length = request.headers["content-length"];
23
- if (length !== undefined && BigInt(length) > limit) {
24
- return yield* new RequestBodyTooLarge({ limit, request });
21
+ if (length !== undefined && BigInt(length) > maxBodySize) {
22
+ return yield* new RequestBodyTooLarge({ limit });
25
23
  }
26
24
  return yield* request.arrayBuffer.pipe(
27
25
  Effect.catchIf(
28
26
  (error) => error.reason._tag === "RequestParseError" && error.reason.reason === "BodyTooLarge",
29
- () => new RequestBodyTooLarge({ limit, request }),
27
+ () => new RequestBodyTooLarge({ limit }),
30
28
  ),
31
29
  );
32
30
  });