@fastly/compute-js-static-publish 4.0.0-alpha.2 → 4.0.0-alpha.4

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/README.md CHANGED
@@ -8,16 +8,16 @@ Using a static site generator to build your website? Do you simply need to serve
8
8
  ## New! Version 4
9
9
 
10
10
  Version 4 of this tool has some awesome new features:
11
- - Support for optionally serving files from Fastly's [Object Store](https://www.fastly.com/blog/introducing-the-compute-edge-object-store-global-persistent-storage-for-compute-functions) instead of bundling them into the Wasm module. See [Object Store](#object-store) below for more information.
12
- - Your scaffolded application no longer uses a bundler by default, making the use of Webpack optional
13
- - Brotli and Gzip compression
14
- - Support for returning `304 Not Modified` status based on `If-None-Match` and `If-Modified-Since` request headers
15
- - `PublisherServer` class to map incoming requests to asset paths
16
- - Ability to include files in the publishing that won't necessarily be served by `PublisherServer`. The content of these files are available to your application and may be useful for reading data written by third-party tools, etc.
17
- - Makes content and metadata available to your application, giving your applications access to their content by their pre-package path/file
18
- - Even load JavaScript files as code into your Compute@Edge JavaScript application
11
+ - Support for serving files from Fastly's [Object Store](#object-store) instead of bundling them into the Wasm module.
12
+ - Scaffolded applications no longer use a bundler by default (Webpack is optional).
13
+ - Brotli and Gzip compression.
14
+ - Support for returning `304 Not Modified` status based on `If-None-Match` and `If-Modified-Since` request headers.
15
+ - [`PublisherServer`](#publisherserver) class to map incoming requests to asset paths.
16
+ - Support for publishing files that won't necessarily be served by `PublisherServer`. File contents are made available to your application–useful, e.g., for reading data written by third-party tools, etc.
17
+ - Makes content and metadata available to your application, via pre-package path/file.
18
+ - Support for loading JavaScript files as code into your Compute@Edge application.
19
19
 
20
- If you wish to update to this version, you may need to re-scaffold your application, or follow the migrations steps outlined in [MIGRATING.md](./MIGRATING.md).
20
+ If you wish to update to this version, you may need to re-scaffold your application, or follow the steps outlined in [MIGRATING.md](./MIGRATING.md).
21
21
 
22
22
  ## Prerequisites
23
23
 
@@ -35,7 +35,7 @@ Assuming the root of your output directory is `./public`,
35
35
  npx @fastly/compute-js-static-publish@latest --root-dir=./public
36
36
  ```
37
37
 
38
- This will generate a Compute@Edge application at `./compute-js`. It will add a default `./src/index.js` file that instantiates the `PublisherServer` class and runs it to serve the static files from your project.
38
+ This will generate a Compute@Edge application at `./compute-js`. It will add a default `./src/index.js` file that instantiates the [`PublisherServer`](#publisherserver) class and runs it to serve the static files from your project.
39
39
 
40
40
  > This process creates a `./static-publish.rc.js` to hold your configuration. This, as well as the other files created in your new Compute@Edge program at `./compute-js`, can be committed to source control (except for the ones we specify in `.gitignore`!)
41
41
 
@@ -65,12 +65,12 @@ Once your application is scaffolded, `@fastly/compute-js-static-publish` integra
65
65
  running as part of your build process.
66
66
 
67
67
  The files you have configured to be included (`--root-dir`) are enumerated and prepared. Their contents are included into
68
- your Wasm binary (or made available via Object Store, if so configured). This process is called "publishing".
68
+ your Wasm binary (or made available via [Object Store](#object-store), if so configured). This process is called "publishing".
69
69
 
70
70
  Once the files are published, they are available to the other source files in the Compute@Edge application. For example,
71
- the stock application simply runs the [PublisherServer](#publisherserver) class to serve up these files.
71
+ the stock application runs the [PublisherServer](#publisherserver) class to serve these files.
72
72
 
73
- For more advanced uses, such as accessing the contents of these file in your own application, see the
73
+ For more advanced uses, such as accessing the contents of these file in your application, see the
74
74
  [Using the packaged objects in your own application](#using-published-assets-in-your-own-application) section below.
75
75
 
76
76
  Publishing is meant to run each time before building your Compute@Edge application into a Wasm file.
@@ -79,9 +79,9 @@ If the files in `--root-dir` have changed, then a new set of files will be publi
79
79
  ### Content Compression
80
80
 
81
81
  During publishing, this tool supports pre-compression of content. By default, your assets are compressed using the Brotli
82
- and gzip algorithms, and then stored alongside the original files in your Wasm artifact (or Object Store).
82
+ and gzip algorithms, and then stored alongside the original files in your Wasm binary (or [Object Store](#object-store)).
83
83
 
84
- > Note: By default, pre-compressed content assets are not generated when the object store is not used.
84
+ > Note: By default, pre-compressed content assets are not generated when the Object Store is not used.
85
85
  This is done to prevent the inclusion multiple of copies of each asset from making the Wasm binary too large.
86
86
  If you want to pre-compress assets when not using Object Store, add a value for 'contentCompression' to your
87
87
  `static-publish.rc.js` file.
@@ -125,10 +125,10 @@ Used to populate the `server` key under `static-publish.rc.js`.
125
125
  |------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
126
126
  | `public-dir` | <root-dir> | The directory that contains your website's public files. |
127
127
  | `static-dir` | (None) | Any directories under `--public-dir` that contain the website's static assets that will be served with a very long TTL. You can specify as many such directories as you wish, by listing multiple items. |
128
- | `auto-ext` | `.html,.htm` | Configuration for automatic file extensions. |
129
- | `auto-index` | `index.html,index.htm` | Configuration for automatically serving an index file. |
130
- | `spa` | (None) | Configuration for serving a fallback file for SPA applications. |
131
- | `not-found-page` | `<public-dir>/404.html` | Configuration for serving a 404 not found file. |
128
+ | `auto-ext` | `.html,.htm` | Specify automatic file extensions. |
129
+ | `auto-index` | `index.html,index.htm` | Specify filenames for automatically serving an index file. |
130
+ | `spa` | (None) | Path to a fallback file for SPA applications. |
131
+ | `not-found-page` | `<public-dir>/404.html` | Path to a fallback file for 404 Not Found. |
132
132
 
133
133
  See [PublisherServer](#publisherserver) for more information about these features.
134
134
 
@@ -140,13 +140,13 @@ Note that the files referenced by `--spa` and `--not-found-page` do not necessar
140
140
 
141
141
  These arguments are used to populate the `fastly.toml` and `package.json` files of your Compute@Edge application.
142
142
 
143
- | Option | Default | Description |
144
- |---------------------|------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
145
- | `name` | `name` from `package.json`, or `compute-js-static-site` | The name of your Compute@Edge application. |
146
- | `description` | `description` from `package.json`, or `Compute@Edge static site` | The description of your Compute@Edge application. |
147
- | `author` | `author` from `package.json`, or `you@example.com` | The author of your Compute@Edge application. |
148
- | `service-id` | (None) | The ID of an existing Fastly WASM service for your Compute@Edge application. |
149
- | `object-store-name` | (None) | The name of a Fastly Object Store to hold the content assets. It must be linked to the service specified by `--service-id`. |
143
+ | Option | Default | Description |
144
+ |---------------------|------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
145
+ | `name` | `name` from `package.json`, or `compute-js-static-site` | The name of your Compute@Edge application. |
146
+ | `description` | `description` from `package.json`, or `Compute@Edge static site` | The description of your Compute@Edge application. |
147
+ | `author` | `author` from `package.json`, or `you@example.com` | The author of your Compute@Edge application. |
148
+ | `service-id` | (None) | The ID of an existing Fastly WASM service for your Compute@Edge application. |
149
+ | `object-store-name` | (None) | The name of a [Fastly Object Store](https://www.fastly.com/blog/introducing-the-compute-edge-object-store-global-persistent-storage-for-compute-functions) to hold the content assets. It must be linked to the service specified by `--service-id`. |
150
150
 
151
151
  ## Usage with frameworks and static site generators
152
152
 
@@ -169,12 +169,12 @@ You may still override any of these options individually.
169
169
 
170
170
  ## PublisherServer
171
171
 
172
- Publisher Server is a simple yet powerful server that can be used out of the box to serve the files prepared by this tool.
172
+ `PublisherServer` is a simple yet powerful server that can be used out of the box to serve the files prepared by this tool.
173
173
 
174
174
  This server handles the following automatically:
175
175
 
176
176
  * Maps the path of your request to a path under `--public-dir` and serves the content of the asset
177
- * Sources the content from the content packaged in the Wasm, or from the Object Store if so configured (see [Object Store](#object-store), below.)
177
+ * Sources the content from the content packaged in the Wasm binary, or from the [Object Store](#object-store), if configured.
178
178
  * Applies long-lived cache headers to files served from `--static-dir` directories. Files under these directories will be cached by the browser for 1 year. (Use versioned or hashed filenames to avoid serving stale assets.)
179
179
  * Performs Brotli and gzip compression as requested by the `Accept-Encoding` headers.
180
180
  * Provides `Last-Modified` and `ETag` response headers, and uses them with `If-Modified-Since` and `If-None-Match` request headers to produce `304 Not Modified` responses.
@@ -210,9 +210,9 @@ For `compression`, the following values are allowed:
210
210
 
211
211
  ## Using the Object Store (BETA) <a name="object-store"></a>
212
212
 
213
- Starting v4, it's now possible to upload assets to and serve them from the Fastly Object Store.
213
+ Starting with v4, it's now possible to upload assets to and serve them from a [Fastly Object Store](https://www.fastly.com/blog/introducing-the-compute-edge-object-store-global-persistent-storage-for-compute-functions).
214
214
 
215
- Fastly Object Store is currently part of a [beta release](https://docs.fastly.com/products/fastly-product-lifecycle#beta),
215
+ Fastly Object Store (globally persistent storage for Compute@Edge applications) is currently part of a [beta release](https://docs.fastly.com/products/fastly-product-lifecycle#beta),
216
216
  and to use it you will need to have the feature enabled for your account.
217
217
 
218
218
  To enable the use of Object Store with `@fastly/compute-js-static-publish`, you will need to perform the following steps:
@@ -221,7 +221,7 @@ To enable the use of Object Store with `@fastly/compute-js-static-publish`, you
221
221
  compute publish` your application.
222
222
 
223
223
  * Create an Object Store under your Fastly account. At the moment you need to use the Fastly CLI. Once the Object Store
224
- is created, it must be linked to your Fastly service using the Resources API.
224
+ is created, it must be linked to your Fastly service using the [Resource API](https://developer.fastly.com/reference/api/services/resource/#create-resource).
225
225
 
226
226
  ```shell
227
227
  # Create an object store
@@ -233,9 +233,9 @@ $ curl -i -X POST "https://api.fastly.com/service/YOUR_FASTLY_SERVICE_ID/version
233
233
 
234
234
  Object Store API: https://developer.fastly.com/reference/cli/object-store/create/
235
235
 
236
- Resources API: https://developer.fastly.com/reference/api/services/resource/
236
+ Resource API: https://developer.fastly.com/reference/api/services/resource/
237
237
 
238
- * Once the object store is created and linked to your service, add the Object Store's name to your `static-publish.rc.js`
238
+ * Once the Object Store is created and linked to your service, add its name to your `static-publish.rc.js`
239
239
  file under the `objectStore` key.
240
240
 
241
241
  After you have done the above steps, go ahead and build your application as normal. If you use `fastly compute build --verbose`
@@ -349,7 +349,7 @@ And that's it! It should be possible to run this task to clean up once in a whil
349
349
 
350
350
  > Note that content types are tested at publishing time, not at runtime.
351
351
 
352
- * `server` - Configuration of `PublisherServer()`. See the [Configuring PublisherServer](#configuring-publisherserver) section
352
+ * `server` - [Configuration of `PublisherServer()`](#configuring-publisherserver).
353
353
  above.
354
354
 
355
355
  ### Running custom code alongside Publisher Server
@@ -358,22 +358,23 @@ The generated `./src/index.js` program instantiates the server and simply asks i
358
358
 
359
359
  You are free to add code to this file.
360
360
 
361
- For example, if the server is unable to formulate a response to the request, then it returns `null`. You may add your
362
- own code to handle these cases, such as to provide custom responses.
361
+ For example, if the `PublisherServer` is unable to formulate a response to the request, then it returns `null`. You may
362
+ add your own code to handle these cases, such as to provide custom responses.
363
363
 
364
364
  ```js
365
365
  import { getServer } from './statics.js';
366
- const server = getServer();
366
+ const staticContentServer = getServer();
367
367
 
368
368
  addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
369
369
  async function handleRequest(event) {
370
370
 
371
- const response = await server.serveRequest(event.request);
371
+ const response = await staticContentServer.serveRequest(event.request);
372
372
  if (response != null) {
373
373
  return response;
374
374
  }
375
375
 
376
376
  // Do custom things here!
377
+ // Handle API requests, serve non-static responses, etc.
377
378
 
378
379
  return new Response('Not found', { status: 404 });
379
380
  }
@@ -385,7 +386,7 @@ Publishing, as described earlier, is the process of preparing files for inclusio
385
386
  This process also makes metadata available about each of the files that are included, such as its content type, the last
386
387
  modified date, the file hash, and so on.
387
388
 
388
- The `PublisherServer` class that is used by the default scaffolded application is one simple application of this content
389
+ The [`PublisherServer` class](#publisherserver) used by the default scaffolded application is a simple application of this content
389
390
  and metadata. By importing `./statics.js` into your Compute@Edge application, you can just as easily access this
390
391
  information about the assets that were included during publishing.
391
392
 
@@ -516,8 +517,8 @@ See the definition of `ContentAssetMetadataMapEntry` in the [`types/content-asse
516
517
 
517
518
  ### Using Webpack
518
519
 
519
- As of v4, Webpack is no longer required, and by default is no longer part of the default scaffolded application.
520
- If you wish to use some features of Webpack, you can elect to include Webpack in your generated application by specifying
520
+ As of v4, Webpack is no longer required, and is no longer part of the default scaffolded application.
521
+ If you wish to use some features of Webpack, you may include Webpack in your generated application by specifying
521
522
  `--webpack` at the command line.
522
523
 
523
524
  ## Migrating
@@ -1 +1 @@
1
- {"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build-static.ts"],"names":[],"mappings":"AAuCA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AA6IhD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAoe5F"}
1
+ {"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build-static.ts"],"names":[],"mappings":"AA+DA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AA6IhD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAoe5F"}
@@ -2,33 +2,60 @@
2
2
  // public folder to be served.
3
3
  // e.g., with create-react-app, this would be the ./build directory.
4
4
  // Outputs:
5
+ //
5
6
  // statics-metadata.js
6
- // deploymentId: string - deployment ID
7
- // contentAssetMetadataMap: Map<string, ContentAssetMetadata> - mapping of asset keys to their metadata
8
- // - key: filename relative to public dir (e.g., /foo/index.html)
9
- // - value:
10
- // - size (to be implemented soon): number - File size in bytes
11
- // - contentType: string - MIME type
12
- // - timestamp (to be implemented soon): last modified time as unix time
13
- // - etag (to be implemented soon): string - Etag
14
- // - text: boolean - whether this is a text file
7
+ //
8
+ // objectStoreName: string - Name of object store, or null if not used.
9
+ // contentAssetMetadataMap: Map<string, ContentAssetMetadataMapEntry> - mapping of asset keys to their metadata
10
+ // - key: string - assetKey, the filename relative to root dir (e.g., /public/foo/index.html)
11
+ // - value: ContentAssetMetadataMapEntry - metadata for asset
12
+ //
13
+ // ContentAssetMetadataMapEntry structure
14
+ // - assetKey: string - filename relative to root dir
15
+ // - contentType: string - MIME type
16
+ // - text: boolean - whether this is a text file
17
+ // - lastModifiedTime: number - last modified time as unix time (seconds)
18
+ // - fileInfo: FileInfo - information about the file
19
+ // - compressedFileInfos: Map<string, FileInfo> - information about any compressed versions
20
+ // - key: string - compression algorithm name (e.g., "gzip", "br", etc.)
21
+ // - value: FileInfo - information about the compressed version of the file
22
+ // - isInline: boolean - whether this file is "inline". If false, object is in the object store.
23
+ // FileInfo structure
24
+ // - hash: string - SHA-256 hash of file
25
+ // - size: number - file size in bytes
26
+ // - staticFilePath: string - path to file in local filesystem, relative to root dir
27
+ // - objectStoreKey: string - object store key, present only for items in object store
28
+ //
15
29
  // statics.js
16
- // imports statics-metadata.js and adds utilities to load the files
17
- // contentAssetMap: Map<string, ContentAsset>
18
- // - key: filename relative to public dir (e.g., /foo/index.html)
19
- // - value:
20
- // - getMetadata() - gets the metadata entry
21
- // - getBody() - gets a Body object that represents the asset
22
- // moduleAssetMap: Map<string, ModuleAsset>
23
- // - key: filename relative to public dir (e.g., /foo/index.html)
24
- // - value:
25
- // - getMetadata() - gets the metadata entry
26
- // - async getModule() - Returns a promise that imports the module and returns a reference.
27
- // This simply returns the statically imported module if it is statically imported.
28
- // - getStaticModule() - Advanced. Returns the statically imported module, or null.
29
- // This also reexports values like the "spa" value in the static-publish.rc.js
30
- // file so that the C@E handler knows what file to serve up if
31
- // the resource doesn't map to a file.
30
+ // imports statics-metadata.js and adds utilities for working with the content assets, as well as
31
+ // for loading module assets. Also gives access to StaticPublisher and its config.
32
+ // See README.md for details
33
+ //
34
+ // moduleAssetMap: Map<string, ModuleAssetMapEntry>
35
+ // - key: string - assetKey, the filename relative to root dir (e.g., /module/hello.js)
36
+ // - value: ModuleAssetMapEntry - information about the module
37
+ //
38
+ // ModuleAssetMapEntry structure
39
+ // - isStaticImport: boolean - if true, then uses a static import statement to load the module
40
+ // - if false, then module is loaded when getModule is called
41
+ // - module: any - the statically loaded module if isStaticImport is true, or null
42
+ // - loadModule: function - a function that dynamically loads the module and returns it, if isStaticImport is false, or null
43
+ //
44
+ // contentAssets: ContentAssets instance
45
+ // moduleAssets: ModuleAssets instance
46
+ //
47
+ // getServer(): function - instantiates PublisherServer singleton and returns it
48
+ // serverConfig: PublisherServerConfigNormalized - publisher server config settings
49
+ //
50
+ // PublisherServerConfigNormalized structure
51
+ // - publicDirPrefix: string
52
+ // - staticItems: string[]
53
+ // - compression: string[]
54
+ // - spaFile: string or null
55
+ // - notFoundPageFile: string or null
56
+ // - autoExt: string[]
57
+ // - autoIndex: string[]
58
+ //
32
59
  import * as fs from "fs";
33
60
  import * as path from "path";
34
61
  import * as url from "url";
@@ -520,7 +520,7 @@ const config = {
520
520
  // excludeDotFiles: true,
521
521
  // includeWellKnown: true,
522
522
  // contentAssetInclusionTest: (filename) => true,
523
- // contentCompression: [ 'br', 'gzip' ],
523
+ // contentCompression: [ 'br', 'gzip' ], // For this config value, default is [] if objectStoreName is null.
524
524
  // moduleAssetInclusionTest: (filename) => false,
525
525
  // contentTypes: [
526
526
  // { test: /.custom$/, contentType: 'application/x-custom', text: false },
@@ -1,7 +1,7 @@
1
1
  export declare abstract class AssetManager<TAsset> {
2
2
  protected readonly assets: Record<string, TAsset>;
3
3
  protected constructor();
4
- setAsset(assetKey: string, asset: TAsset): void;
4
+ protected initAsset(assetKey: string, asset: TAsset): void;
5
5
  getAsset(assetKey: string): TAsset | null;
6
6
  }
7
7
  //# sourceMappingURL=asset-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asset-manager.d.ts","sourceRoot":"","sources":["../../../src/server/assets/asset-manager.ts"],"names":[],"mappings":"AAAA,8BAAsB,YAAY,CAAC,MAAM;IAEvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElD,SAAS;IAIT,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAI1C"}
1
+ {"version":3,"file":"asset-manager.d.ts","sourceRoot":"","sources":["../../../src/server/assets/asset-manager.ts"],"names":[],"mappings":"AAAA,8BAAsB,YAAY,CAAC,MAAM;IAEvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElD,SAAS;IAIT,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAInD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAI1C"}
@@ -2,7 +2,7 @@ export class AssetManager {
2
2
  constructor() {
3
3
  this.assets = {};
4
4
  }
5
- setAsset(assetKey, asset) {
5
+ initAsset(assetKey, asset) {
6
6
  this.assets[assetKey] = asset;
7
7
  }
8
8
  getAsset(assetKey) {
@@ -136,7 +136,7 @@ export class ContentAssets extends AssetManager {
136
136
  }
137
137
  asset = new ContentObjectStoreAsset(metadata, objectStoreName);
138
138
  }
139
- this.setAsset(assetKey, asset);
139
+ this.initAsset(assetKey, asset);
140
140
  }
141
141
  }
142
142
  }
@@ -39,7 +39,7 @@ export class ModuleAssets extends AssetManager {
39
39
  else {
40
40
  asset = new ModuleAssetDynamic(assetKey, moduleEntry.loadModule);
41
41
  }
42
- this.setAsset(assetKey, asset);
42
+ this.initAsset(assetKey, asset);
43
43
  }
44
44
  }
45
45
  }
@@ -1,6 +1,6 @@
1
1
  // A class designed to give a Body-style interface to Uint8Array.
2
2
  // The intended use case is arrays brought in from includeBytes().
3
- export class InlineStoreEntry {
3
+ class InlineStoreEntry {
4
4
  constructor(array, contentEncoding, hash, size) {
5
5
  this._body = new ReadableStreamForBytes(array);
6
6
  this._consumed = false;
@@ -63,6 +63,7 @@ export class InlineStoreEntry {
63
63
  }
64
64
  }
65
65
  InlineStoreEntry.decoder = new TextDecoder();
66
+ export { InlineStoreEntry };
66
67
  class ReadableStreamForBytes extends ReadableStream {
67
68
  constructor(array) {
68
69
  super({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fastly/compute-js-static-publish",
3
3
  "type": "module",
4
- "version": "4.0.0-alpha.2",
4
+ "version": "4.0.0-alpha.4",
5
5
  "description": "Static Publisher for Compute@Edge JavaScript",
6
6
  "main": "./build/index.js",
7
7
  "types": "./build/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "@types/glob-to-regexp": "^0.4.1",
41
41
  "@types/node": "^18.0.0",
42
42
  "rimraf": "^4.3.0",
43
- "typescript": "^4.9.5"
43
+ "typescript": "^5.0.2"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=18"
@@ -1,17 +1,18 @@
1
1
  /// <reference types="@fastly/js-compute" />
2
-
3
2
  import { getServer } from './statics.js';
4
- const server = getServer();
3
+ const staticContentServer = getServer();
5
4
 
6
5
  // eslint-disable-next-line no-restricted-globals
7
6
  addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
8
7
  async function handleRequest(event) {
9
8
 
10
- const response = await server.serveRequest(event.request);
11
-
9
+ const response = await staticContentServer.serveRequest(event.request);
12
10
  if (response != null) {
13
11
  return response;
14
12
  }
15
13
 
14
+ // Do custom things here!
15
+ // Handle API requests, serve non-static responses, etc.
16
+
16
17
  return new Response('Not found', { status: 404 });
17
18
  }