@bunary/http 0.0.4 → 0.0.5

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 CHANGED
@@ -5,6 +5,46 @@ All notable changes to `@bunary/http` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.0.5] - 2026-01-28
9
+
10
+ ### Added
11
+
12
+ - `RequestContext.locals` for per-request middleware state (isolated between concurrent requests)
13
+
14
+ ## [0.0.4] - 2026-01-26
15
+
16
+ ### Added
17
+
18
+ - Optional route parameters using `:param?` syntax
19
+ - Routes can match with or without optional parameters
20
+ - Optional params are `undefined` in `ctx.params` when not provided
21
+ - Supports multiple optional parameters in a single route
22
+ - Works with route constraints
23
+ - Comprehensive test suite for optional parameters
24
+
25
+ ## [0.0.3] - 2026-01-26
26
+
27
+ ### Added
28
+
29
+ - Route Groups with `app.group()` method
30
+ - Prefix routes with shared path prefix
31
+ - Apply middleware to groups of routes
32
+ - Add name prefixes for named routes in groups
33
+ - Support nested groups
34
+ - Named Routes with `.name()` method
35
+ - Assign names to routes for URL generation
36
+ - Generate URLs with `app.route(name, params)`
37
+ - Check route existence with `app.hasRoute(name)`
38
+ - List all routes with `app.getRoutes()`
39
+ - Support query string parameters in URL generation
40
+ - Route Constraints with `.where()` method
41
+ - Validate route parameters with regex patterns
42
+ - Helper methods: `whereNumber()`, `whereAlpha()`, `whereAlphaNumeric()`, `whereUuid()`, `whereUlid()`, `whereIn()`
43
+ - Support string or RegExp patterns
44
+ - Multiple constraints per route
45
+ - Constraints work with optional parameters
46
+ - Comprehensive test suites for groups, named routes, and constraints
47
+
8
48
  ## [0.0.2] - 2026-01-24
9
49
 
10
50
  ### Added
package/README.md CHANGED
@@ -4,6 +4,10 @@ A lightweight, type-safe HTTP framework built exclusively for [Bun](https://bun.
4
4
 
5
5
  Part of the [Bunary](https://github.com/bunary-dev) ecosystem - a Bun-first backend platform inspired by Laravel.
6
6
 
7
+ ## Documentation
8
+
9
+ Canonical documentation for this package lives in [`docs/index.md`](./docs/index.md).
10
+
7
11
  ## Features
8
12
 
9
13
  - 🚀 **Bun-native** - Uses `Bun.serve()` directly, no Node.js compatibility layer
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACX,SAAS,EAYT,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAmOrC"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACX,SAAS,EAYT,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAoOrC"}
package/dist/index.js CHANGED
@@ -327,7 +327,8 @@ function createApp() {
327
327
  const ctx = {
328
328
  request,
329
329
  params: match.params,
330
- query: url.searchParams
330
+ query: url.searchParams,
331
+ locals: {}
331
332
  };
332
333
  try {
333
334
  const allMiddleware = getMiddlewareChain(match.route);
@@ -18,5 +18,19 @@ export interface RequestContext {
18
18
  params: PathParams;
19
19
  /** Query parameters from the URL search string */
20
20
  query: URLSearchParams;
21
+ /**
22
+ * Per-request storage for middleware and handlers.
23
+ *
24
+ * This object is **initialized per request** (never shared across requests).
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * app.use(async (ctx, next) => {
29
+ * ctx.locals.userId = "123";
30
+ * return await next();
31
+ * });
32
+ * ```
33
+ */
34
+ locals: Record<string, unknown>;
21
35
  }
22
36
  //# sourceMappingURL=requestContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestContext.d.ts","sourceRoot":"","sources":["../../src/types/requestContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,cAAc;IAC9B,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,MAAM,EAAE,UAAU,CAAC;IACnB,kDAAkD;IAClD,KAAK,EAAE,eAAe,CAAC;CACvB"}
1
+ {"version":3,"file":"requestContext.d.ts","sourceRoot":"","sources":["../../src/types/requestContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,cAAc;IAC9B,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,uDAAuD;IACvD,MAAM,EAAE,UAAU,CAAC;IACnB,kDAAkD;IAClD,KAAK,EAAE,eAAe,CAAC;IACvB;;;;;;;;;;;;OAYG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunary/http",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "HTTP routing and middleware for Bunary - a Bun-first backend framework inspired by Laravel",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,6 +37,10 @@
37
37
  "type": "git",
38
38
  "url": "https://github.com/bunary-dev/http.git"
39
39
  },
40
+ "homepage": "https://github.com/bunary-dev/http#readme",
41
+ "bugs": {
42
+ "url": "https://github.com/bunary-dev/http/issues"
43
+ },
40
44
  "engines": {
41
45
  "bun": ">=1.0.0"
42
46
  },