@fastly/compute-js-static-publish 7.0.0-beta.0 → 7.0.0-beta.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/README.md
CHANGED
|
@@ -36,8 +36,8 @@ When you're ready to go live, [create a free Fastly account](https://www.fastly.
|
|
|
36
36
|
|
|
37
37
|
```sh
|
|
38
38
|
cd compute-js
|
|
39
|
-
npm run
|
|
40
|
-
npm run publish-content # upload your static files
|
|
39
|
+
npm run publish-service # deploy the app (publish the "service")
|
|
40
|
+
npm run publish-content # upload your static files (publish the "content")
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Features
|
package/README.short.md
CHANGED
|
@@ -36,8 +36,8 @@ When you're ready to go live, [create a free Fastly account](https://www.fastly.
|
|
|
36
36
|
|
|
37
37
|
```sh
|
|
38
38
|
cd compute-js
|
|
39
|
-
npm run
|
|
40
|
-
npm run publish-content # upload your static files
|
|
39
|
+
npm run publish-service # deploy the app (publish the "service")
|
|
40
|
+
npm run publish-content # upload your static files (publish the "content")
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Features
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-app.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init-app.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AA0QF,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"init-app.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init-app.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AA0QF,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,iBA6d1C"}
|
|
@@ -496,7 +496,7 @@ export async function action(argv) {
|
|
|
496
496
|
scripts: {
|
|
497
497
|
prestart: "npx @fastly/compute-js-static-publish publish-content --local-only",
|
|
498
498
|
start: "fastly compute serve",
|
|
499
|
-
|
|
499
|
+
"publish-service": "fastly compute publish",
|
|
500
500
|
"publish-content": 'npx @fastly/compute-js-static-publish publish-content',
|
|
501
501
|
build: 'js-compute-runtime ./src/index.js ./bin/main.wasm'
|
|
502
502
|
},
|
|
@@ -612,6 +612,7 @@ export default config;
|
|
|
612
612
|
// src/index.js
|
|
613
613
|
resourceFiles['./src/index.js'] = /* language=text */ `\
|
|
614
614
|
/// <reference types="@fastly/js-compute" />
|
|
615
|
+
import { env } from 'fastly:env';
|
|
615
616
|
import { PublisherServer } from '@fastly/compute-js-static-publish';
|
|
616
617
|
import rc from '../static-publish.rc.js';
|
|
617
618
|
const publisherServer = PublisherServer.fromStaticPublishRc(rc);
|
|
@@ -620,7 +621,11 @@ const publisherServer = PublisherServer.fromStaticPublishRc(rc);
|
|
|
620
621
|
addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
|
|
621
622
|
async function handleRequest(event) {
|
|
622
623
|
|
|
623
|
-
|
|
624
|
+
console.log('FASTLY_SERVICE_VERSION', env('FASTLY_SERVICE_VERSION'));
|
|
625
|
+
|
|
626
|
+
const request = event.request;
|
|
627
|
+
|
|
628
|
+
const response = await publisherServer.serveRequest(request);
|
|
624
629
|
if (response != null) {
|
|
625
630
|
return response;
|
|
626
631
|
}
|
|
@@ -651,6 +656,7 @@ async function handleRequest(event) {
|
|
|
651
656
|
console.log('To build and deploy to your Compute service:');
|
|
652
657
|
console.log('');
|
|
653
658
|
console.log(' cd ' + COMPUTE_JS_DIR);
|
|
654
|
-
console.log(' npm run
|
|
659
|
+
console.log(' npm run publish-service');
|
|
660
|
+
console.log(' npm run publish-content');
|
|
655
661
|
console.log('');
|
|
656
662
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/publisher-server/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAA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AAE,OAAO,GAAG,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC;IAoDjF,iBAAiB,CAAC,QAAQ,EAAE,MAAM;IAcxC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,OAAO,GAAG,QAAQ,GAAG,IAAI;IA6DxF,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;YAkC/G,0CAA0C;IAyClD,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiDtF,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAqE/D"}
|
|
@@ -53,7 +53,6 @@ export class PublisherServer {
|
|
|
53
53
|
this.collectionNameHeader = collectionHeader;
|
|
54
54
|
}
|
|
55
55
|
// Server config is obtained from the KV Store, and cached for the duration of this object.
|
|
56
|
-
// TODO get from simple cache
|
|
57
56
|
async getServerConfig() {
|
|
58
57
|
const settingsFileKey = `${this.publishId}_settings_${this.activeCollectionName}`;
|
|
59
58
|
const kvStore = new KVStore(this.kvStoreName);
|
|
@@ -368,6 +367,10 @@ export class PublisherServer {
|
|
|
368
367
|
}
|
|
369
368
|
const url = new URL(request.url);
|
|
370
369
|
const pathname = decodeURI(url.pathname);
|
|
370
|
+
// Custom health check route
|
|
371
|
+
if (pathname === '/healthz') {
|
|
372
|
+
return new Response("OK", { status: 200 });
|
|
373
|
+
}
|
|
371
374
|
const serverConfig = await this.getServerConfig();
|
|
372
375
|
if (serverConfig == null) {
|
|
373
376
|
return new Response(`Settings not found. You may need to publish your application.`, {
|