@fastly/hono-fastly-compute 0.3.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 +8 -1
- package/build/fire.d.ts +25 -22
- package/build/fire.js +1 -3
- package/build/handler.d.ts +10 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.1] - 2025-10-08
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Fix typings when bindings are empty
|
|
15
|
+
|
|
10
16
|
## [0.3.0] - 2025-10-06
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -19,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
25
|
|
|
20
26
|
- Initial public release
|
|
21
27
|
|
|
22
|
-
[unreleased]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.
|
|
28
|
+
[unreleased]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.1...HEAD
|
|
29
|
+
[0.3.1]: https://github.com/fastly/hono-fastly-compute/compare/v0.3.0...v0.3.1
|
|
23
30
|
[0.3.0]: https://github.com/fastly/hono-fastly-compute/compare/v0.1.0...v0.3.0
|
|
24
31
|
[0.1.0]: https://github.com/fastly/hono-fastly-compute/releases/tag/v0.1.0
|
package/build/fire.d.ts
CHANGED
|
@@ -2,32 +2,35 @@ import type { Schema } from 'hono';
|
|
|
2
2
|
import type { HonoBase } from 'hono/hono-base';
|
|
3
3
|
import type { ContextProxy, BindingsDefs } from '@fastly/compute-js-context';
|
|
4
4
|
import { type HandleOptions } from './handler.js';
|
|
5
|
+
/**
|
|
6
|
+
* Registers a Hono app to handle fetch events in Fastly Compute.
|
|
7
|
+
*
|
|
8
|
+
* This sets up `addEventListener('fetch', handle(app, envBindingsDefs, options))`
|
|
9
|
+
* using the bindings you passed to `buildFire()`.
|
|
10
|
+
*
|
|
11
|
+
* @param app - The Hono application instance to serve
|
|
12
|
+
* @param options - Options for handling requests (fetch defaults to undefined)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const fire = buildFire({ foo: "KVStore" });
|
|
16
|
+
*
|
|
17
|
+
* type Env = {
|
|
18
|
+
* Variables: Variables;
|
|
19
|
+
* Bindings: typeof fire.Bindings;
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* const app = new Hono<Env>();
|
|
23
|
+
* fire(app);
|
|
24
|
+
*/
|
|
5
25
|
type FireFn<D extends BindingsDefs> = {
|
|
6
|
-
/**
|
|
7
|
-
* Registers a Hono app to handle fetch events in Fastly Compute.
|
|
8
|
-
*
|
|
9
|
-
* This sets up `addEventListener('fetch', handle(app, envBindingsDefs, options))`
|
|
10
|
-
* using the bindings you passed to `buildFire()`.
|
|
11
|
-
*
|
|
12
|
-
* @param app - The Hono application instance to serve
|
|
13
|
-
* @param options - Options for handling requests (fetch defaults to undefined)
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* const fire = buildFire({ foo: "KVStore" });
|
|
17
|
-
*
|
|
18
|
-
* type Env = {
|
|
19
|
-
* Variables: Variables;
|
|
20
|
-
* Bindings: typeof fire.Bindings;
|
|
21
|
-
* };
|
|
22
|
-
*
|
|
23
|
-
* const app = new Hono<Env>();
|
|
24
|
-
* fire(app);
|
|
25
|
-
*/
|
|
26
26
|
<V extends {
|
|
27
27
|
Variables?: object;
|
|
28
|
-
}, S extends Schema, BasePath extends string>(app: HonoBase<(keyof D extends never ? {} :
|
|
28
|
+
}, S extends Schema, BasePath extends string>(app: HonoBase<(keyof D extends never ? {} : never) & V, S, BasePath>, options?: HandleOptions): void;
|
|
29
|
+
<V extends {
|
|
30
|
+
Variables?: object;
|
|
31
|
+
}, S extends Schema, BasePath extends string>(app: HonoBase<{
|
|
29
32
|
Bindings: ContextProxy<D>;
|
|
30
|
-
}
|
|
33
|
+
} & V, S, BasePath>, options?: HandleOptions): void;
|
|
31
34
|
/**
|
|
32
35
|
* The inferred bindings type, derived from the defs passed to `buildFire()`.
|
|
33
36
|
* Use this in your Env definition: `{ Bindings: typeof fire.Bindings }`.
|
package/build/fire.js
CHANGED
|
@@ -34,9 +34,7 @@ import { handle } from './handler.js';
|
|
|
34
34
|
* - Exposes a `.Bindings` type inferred from the given defs
|
|
35
35
|
*/
|
|
36
36
|
export function buildFire(bindingsDefs) {
|
|
37
|
-
const fireFn = ((app, options = {
|
|
38
|
-
fetch: undefined,
|
|
39
|
-
}) => {
|
|
37
|
+
const fireFn = ((app, options = { fetch: undefined, }) => {
|
|
40
38
|
addEventListener('fetch', handle(app, bindingsDefs, options));
|
|
41
39
|
});
|
|
42
40
|
fireFn.defs = bindingsDefs;
|
package/build/handler.d.ts
CHANGED
|
@@ -5,14 +5,19 @@ type Handler = (evt: FetchEvent) => void;
|
|
|
5
5
|
export type HandleOptions = {
|
|
6
6
|
fetch?: typeof fetch;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type HandleFn = {
|
|
9
|
+
<D extends BindingsDefs, V extends {
|
|
10
|
+
Variables?: object;
|
|
11
|
+
}, S extends Schema, BasePath extends string>(app: HonoBase<(keyof D extends never ? {} : never) & V, S, BasePath>, envBindingsDefs: D, opts?: HandleOptions): Handler;
|
|
12
|
+
<D extends BindingsDefs, V extends {
|
|
13
|
+
Variables?: object;
|
|
14
|
+
}, S extends Schema, BasePath extends string>(app: HonoBase<{
|
|
15
|
+
Bindings: ContextProxy<D>;
|
|
16
|
+
} & V, S, BasePath>, envBindingsDefs: D, opts?: HandleOptions): Handler;
|
|
10
17
|
};
|
|
11
18
|
/**
|
|
12
19
|
* Adapter for Fastly Compute
|
|
13
20
|
*/
|
|
14
|
-
export declare const handle:
|
|
15
|
-
Variables?: object;
|
|
16
|
-
}, S extends Schema, BasePath extends string>(app: HonoBase<MaybeBindings<D> & V, S, BasePath>, envBindingsDefs: D, opts?: HandleOptions) => Handler;
|
|
21
|
+
export declare const handle: HandleFn;
|
|
17
22
|
export {};
|
|
18
23
|
//# sourceMappingURL=handler.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastly/hono-fastly-compute",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Helper utilities for using Hono with Fastly Compute",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"clean": "rm -rf build"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@fastly/js-
|
|
30
|
-
"@fastly/
|
|
29
|
+
"@fastly/compute-js-context": "^0.4.2",
|
|
30
|
+
"@fastly/js-compute": "^3.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"hono": "^4.9.5",
|