@fastly/hono-compute-js-static-publish 0.5.1 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -7,25 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [unreleased]
9
9
 
10
- ## [0.5.1] - 2024-10-10
10
+ ## [0.5.3] - 2026-01-07
11
+
12
+ ### Added
13
+
14
+ - Publish using CI
15
+
16
+ ### Fixed
17
+
18
+ - Fix changelog dates
19
+
20
+ ## [0.5.2] - 2025-10-15
21
+
22
+ ### Added
23
+
24
+ - Add fromPublisherServer and fromStaticPublishRc helpers
25
+
26
+ ## [0.5.1] - 2025-10-10
11
27
 
12
28
  ### Fixed
13
29
 
14
30
  - Bump `hono` dependency
15
31
 
16
- ## [0.5.0] - 2024-10-06
32
+ ## [0.5.0] - 2025-10-06
17
33
 
18
34
  ### Changed
19
35
 
20
36
  - BREAKING: Moved to `@fastly` scope
21
37
 
22
- ## [0.3.0] - 2024-08-30
38
+ ## [0.3.0] - 2025-08-30
23
39
 
24
40
  ### Added
25
41
 
26
42
  - Update for @fastly/compute-js-static-publish v7
27
43
 
28
- ## [0.2.0] - 2024-04-26
44
+ ## [0.2.0] - 202-04-26
29
45
 
30
46
  ### Added
31
47
 
@@ -44,7 +60,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
44
60
 
45
61
  - Initial public release
46
62
 
47
- [unreleased]: https://github.com/harmony7/hono-compute-js-static-publish/compare/v0.5.1...HEAD
63
+ [unreleased]: https://github.com/harmony7/hono-compute-js-static-publish/compare/v0.5.3...HEAD
64
+ [0.5.3]: https://github.com/harmony7/hono-compute-js-static-publish/compare/v0.5.2...v0.5.3
65
+ [0.5.2]: https://github.com/harmony7/hono-compute-js-static-publish/compare/v0.5.1...v0.5.2
48
66
  [0.5.1]: https://github.com/harmony7/hono-compute-js-static-publish/compare/v0.5.0...v0.5.1
49
67
  [0.5.0]: https://github.com/harmony7/hono-compute-js-static-publish/compare/v0.3.0...v0.5.0
50
68
  [0.3.0]: https://github.com/harmony7/hono-compute-js-static-publish/compare/v0.2.0...v0.3.0
package/README.md CHANGED
@@ -16,10 +16,9 @@ Works with:
16
16
  import { Hono } from 'hono/quick'
17
17
  import { fire } from 'hono/service-worker'
18
18
 
19
- import { serveStatic } from '@fastly/hono-compute-js-static-publish'
20
- import { PublisherServer } from '@fastly/compute-js-static-publish'
19
+ import { fromStaticPublishRc } from '@fastly/hono-compute-js-static-publish'
21
20
  import rc from '../static-publish.rc.js'
22
- const staticPublisherServer = PublisherServer.fromStaticPublishRc(rc)
21
+ const serveStatic = fromStaticPublishRc(rc)
23
22
 
24
23
  const app = new Hono()
25
24
 
@@ -27,8 +26,8 @@ app.get('/', (c) => {
27
26
  return c.text('Hello Hono!')
28
27
  })
29
28
 
30
- app.get('/favicon.ico', serveStatic({ path: './favicon.ico', staticPublisherServer }))
31
- app.get('/static/*', serveStatic({ root: './', staticPublisherServer }))
29
+ app.get('/favicon.ico', serveStatic({ path: './favicon.ico' }))
30
+ app.get('/static/*', serveStatic({ root: './' }))
32
31
 
33
32
  fire(app)
34
33
  ```
@@ -39,18 +38,18 @@ fire(app)
39
38
  import { Hono } from 'hono/quick'
40
39
  import { fire } from 'hono/service-worker'
41
40
 
42
- import { serveStatic } from '@fastly/hono-compute-js-static-publish'
41
+ import { fromPublisherServer } from '@fastly/hono-compute-js-static-publish'
43
42
  import { getServer } from '../static-publisher/statics.js'
43
+ const serveStatic = fromPublisherServer(getServer())
44
44
 
45
45
  const app = new Hono()
46
46
 
47
47
  app.get('/', (c) => {
48
48
  return c.text('Hello Hono!')
49
- });
49
+ })
50
50
 
51
- const staticPublisherServer = getServer()
52
- app.get('/favicon.ico', serveStatic({ path: './favicon.ico', staticPublisherServer }))
53
- app.get('/static/*', serveStatic({ root: './', staticPublisherServer }))
51
+ app.get('/favicon.ico', serveStatic({ path: './favicon.ico' }))
52
+ app.get('/static/*', serveStatic({ root: './' }))
54
53
 
55
54
  fire(app)
56
55
  ```
@@ -60,10 +59,10 @@ fire(app)
60
59
  > [!NOTE]
61
60
  > The instructions below are for @fastly/compute-js-static-publish v7.
62
61
 
63
- Once you have [set up a Hono project for Fastly Compute](https://hono.dev/getting-started/fastly), add this Adapter, the Fastly CLI, and the Static Publisher library to your application:
62
+ Once you have [set up a Hono project for Fastly Compute](https://hono.dev/getting-started/fastly), add this library and the Static Publisher library to your application:
64
63
 
65
64
  ```
66
- npm install @fastly/hono-compute-js-static-publish @fastly/cli @fastly/compute-js-static-publish
65
+ npm install @fastly/hono-compute-js-static-publish @fastly/compute-js-static-publish
67
66
  ```
68
67
 
69
68
  These directions assume your static files exist directly under the `./assets` subdirectory of your Fastly Compute application.
@@ -72,7 +71,7 @@ You will need to add and modify some files at the root of your project.
72
71
 
73
72
  * Add `static-publish.rc.js`
74
73
  ```javascript
75
- /** @type {import('@fastly/compute-js-static-publish').StaticPublishRc} */
74
+ /** @type {import('@fastly/hono-compute-js-static-publish').StaticPublishRc} */
76
75
  const rc = {
77
76
  kvStoreName: "site-content",
78
77
  publishId: "default",
@@ -89,7 +88,7 @@ You will need to add and modify some files at the root of your project.
89
88
 
90
89
  * Add `publish-content.config.js`
91
90
  ```javascript
92
- /** @type {import('@fastly/compute-js-static-publish').PublishContentConfig} */
91
+ /** @type {import('@fastly/hono-compute-js-static-publish').PublishContentConfig} */
93
92
  const config = {
94
93
  rootDir: './assets'
95
94
  };
@@ -125,18 +124,16 @@ You will need to add and modify some files at the root of your project.
125
124
  ```
126
125
 
127
126
  Finally, modify your application's `src/index.ts` file:
128
- 1. Import `serveStatic` from this library and `PublisherServer` from `@fastly/compute-js-static-publish`
129
- 2. Import the default constant from `static-publish.rc.js` and pass it to `PublisherServer.fromStaticPublishRc()` to obtain an instance of the Publisher Server.
130
- 3. Call `serveStatic` to instantiate [Hono Middleware](https://hono.dev/guides/middleware), passing in the `PublisherServer` instance obtained above.
127
+ 1. Import `fromStaticPublishRc` from this library
128
+ 2. Import the default constant from `static-publish.rc.js` and pass it to `fromStaticPublishRc()` to instantiate the [Hono Middleware](https://hono.dev/guides/middleware).
131
129
 
132
130
  ```typescript
133
131
  import { Hono } from 'hono/quick'
134
132
  import { fire } from 'hono/service-worker'
135
133
 
136
- import { serveStatic } from '@fastly/hono-compute-js-static-publish'
137
- import { PublisherServer } from '@fastly/compute-js-static-publish'
134
+ import { fromStaticPublishRc } from '@fastly/hono-compute-js-static-publish'
138
135
  import rc from '../static-publish.rc.js'
139
- const staticPublisherServer = PublisherServer.fromStaticPublishRc(rc)
136
+ const serveStatic = fromStaticPublishRc(rc)
140
137
 
141
138
  const app = new Hono()
142
139
 
@@ -144,8 +141,8 @@ app.get('/', (c) => {
144
141
  return c.text('Hello Hono!')
145
142
  })
146
143
 
147
- app.get('/favicon.ico', serveStatic({ path: './favicon.ico', staticPublisherServer }))
148
- app.get('/static/*', serveStatic({ root: './', staticPublisherServer }))
144
+ app.get('/favicon.ico', serveStatic({ path: './favicon.ico' }))
145
+ app.get('/static/*', serveStatic({ root: './' }))
149
146
 
150
147
  fire(app)
151
148
  ```
package/build/index.d.ts CHANGED
@@ -1,8 +1,13 @@
1
- import { type PublisherServer } from '@fastly/compute-js-static-publish';
2
- export type ServeStaticOptions = {
1
+ import { PublisherServer, type StaticPublishRc, type PublishContentConfig } from '@fastly/compute-js-static-publish';
2
+ export type ServeStaticMiddlewareOptions = {
3
3
  path?: string;
4
4
  root?: string;
5
+ };
6
+ export type ServeStaticOptions = ServeStaticMiddlewareOptions & {
5
7
  staticPublisherServer: PublisherServer;
6
8
  };
7
- export declare function serveStatic(options: ServeStaticOptions): import("hono/types").MiddlewareHandler<any, string, {}>;
9
+ export declare function serveStatic(options: ServeStaticOptions): import("hono/types").MiddlewareHandler<any, string, {}, Response>;
10
+ export declare function fromPublisherServer(server: PublisherServer): (options: ServeStaticMiddlewareOptions) => import("hono/types").MiddlewareHandler<any, string, {}, Response>;
11
+ export declare function fromStaticPublishRc(rc: StaticPublishRc): (options: ServeStaticMiddlewareOptions) => import("hono/types").MiddlewareHandler<any, string, {}, Response>;
12
+ export { PublisherServer, type StaticPublishRc, type PublishContentConfig };
8
13
  //# sourceMappingURL=index.d.ts.map
package/build/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createMiddleware } from 'hono/factory';
2
+ import { PublisherServer } from '@fastly/compute-js-static-publish';
2
3
  export function serveStatic(options) {
3
4
  const server = options.staticPublisherServer;
4
5
  let root = options.root ?? './';
@@ -21,3 +22,10 @@ export function serveStatic(options) {
21
22
  c.res = await server.serveAsset(c.req.raw, asset, { cache: 'never' });
22
23
  });
23
24
  }
25
+ export function fromPublisherServer(server) {
26
+ return (options) => serveStatic({ ...options, staticPublisherServer: server });
27
+ }
28
+ export function fromStaticPublishRc(rc) {
29
+ return fromPublisherServer(PublisherServer.fromStaticPublishRc(rc));
30
+ }
31
+ export { PublisherServer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastly/hono-compute-js-static-publish",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Serve files from Fastly Compute Static Publisher on Hono",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@fastly/compute-js-static-publish": "^7.0.0",
30
- "hono": "^4.9.10",
30
+ "hono": "^4.11.3",
31
31
  "typescript": "^5.4.5"
32
32
  },
33
33
  "peerDependencies": {