@fastly/compute-js-static-publish 3.6.0 → 4.0.0-alpha.0
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 +440 -103
- package/build/assets/asset-manager.d.ts +7 -0
- package/build/assets/asset-manager.d.ts.map +1 -0
- package/build/assets/asset-manager.js +11 -0
- package/build/assets/content-assets.d.ts +29 -0
- package/build/assets/content-assets.d.ts.map +1 -0
- package/build/assets/content-assets.js +88 -0
- package/build/assets/module-assets.d.ts +23 -0
- package/build/assets/module-assets.d.ts.map +1 -0
- package/build/assets/module-assets.js +45 -0
- package/build/cli/build-static.d.ts.map +1 -0
- package/build/cli/build-static.js +524 -0
- package/build/cli/clean-object-store.d.ts +2 -0
- package/build/cli/clean-object-store.d.ts.map +1 -0
- package/build/cli/cli.d.ts.map +1 -0
- package/build/{cli.js → cli/cli.js} +0 -0
- package/build/cli/commands/build-static.d.ts +3 -0
- package/build/cli/commands/build-static.d.ts.map +1 -0
- package/build/cli/commands/build-static.js +501 -0
- package/build/cli/commands/clean-object-store.d.ts +3 -0
- package/build/cli/commands/clean-object-store.d.ts.map +1 -0
- package/build/cli/commands/clean-object-store.js +54 -0
- package/build/cli/commands/init-app.d.ts.map +1 -0
- package/build/cli/commands/init-app.js +559 -0
- package/build/cli/compression/brotli.d.ts +3 -0
- package/build/cli/compression/brotli.d.ts.map +1 -0
- package/build/cli/compression/brotli.js +15 -0
- package/build/cli/compression/gzip.d.ts +3 -0
- package/build/cli/compression/gzip.d.ts.map +1 -0
- package/build/cli/compression/gzip.js +15 -0
- package/build/cli/compression/index.d.ts +8 -0
- package/build/cli/compression/index.d.ts.map +1 -0
- package/build/cli/compression/index.js +12 -0
- package/build/cli/index.d.ts +3 -0
- package/build/cli/index.d.ts.map +1 -0
- package/build/cli/index.js +86 -0
- package/build/cli/init-app.d.ts +3 -0
- package/build/cli/init-app.d.ts.map +1 -0
- package/build/{init-app.js → cli/init-app.js} +16 -16
- package/build/cli/load-config.d.ts +3 -0
- package/build/cli/load-config.d.ts.map +1 -0
- package/build/cli/load-config.js +357 -0
- package/build/cli/presets/implementations/create-react-app.d.ts +11 -0
- package/build/cli/presets/implementations/create-react-app.d.ts.map +1 -0
- package/build/cli/presets/implementations/create-react-app.js +34 -0
- package/build/cli/presets/implementations/docusaurus.d.ts +7 -0
- package/build/cli/presets/implementations/docusaurus.d.ts.map +1 -0
- package/build/cli/presets/implementations/docusaurus.js +13 -0
- package/build/cli/presets/implementations/gatsby.d.ts +7 -0
- package/build/cli/presets/implementations/gatsby.d.ts.map +1 -0
- package/build/cli/presets/implementations/gatsby.js +13 -0
- package/build/cli/presets/implementations/next.d.ts +7 -0
- package/build/cli/presets/implementations/next.d.ts.map +1 -0
- package/build/cli/presets/implementations/next.js +13 -0
- package/build/cli/presets/implementations/sveltekit.d.ts +7 -0
- package/build/cli/presets/implementations/sveltekit.d.ts.map +1 -0
- package/build/cli/presets/implementations/sveltekit.js +13 -0
- package/build/cli/presets/implementations/vite.d.ts +7 -0
- package/build/cli/presets/implementations/vite.d.ts.map +1 -0
- package/build/cli/presets/implementations/vite.js +13 -0
- package/build/cli/presets/index.d.ts +3 -0
- package/build/cli/presets/index.d.ts.map +1 -0
- package/build/cli/presets/index.js +16 -0
- package/build/cli/presets/preset-base.d.ts +19 -0
- package/build/cli/presets/preset-base.d.ts.map +1 -0
- package/build/cli/util/data.d.ts +7 -0
- package/build/cli/util/data.d.ts.map +1 -0
- package/build/cli/util/data.js +58 -0
- package/build/cli/util/fastly-api.d.ts +10 -0
- package/build/cli/util/fastly-api.d.ts.map +1 -0
- package/build/cli/util/fastly-api.js +47 -0
- package/build/cli/util/files.d.ts +11 -0
- package/build/cli/util/files.d.ts.map +1 -0
- package/build/cli/util/files.js +33 -0
- package/build/cli/util/hash.d.ts +2 -0
- package/build/cli/util/hash.d.ts.map +1 -0
- package/build/cli/util/hash.js +8 -0
- package/build/cli/util/id.d.ts +3 -0
- package/build/cli/util/id.d.ts.map +1 -0
- package/build/cli/util/id.js +17 -0
- package/build/cli/util/object-store.d.ts +16 -0
- package/build/cli/util/object-store.d.ts.map +1 -0
- package/build/cli/util/object-store.js +108 -0
- package/build/cli/util/publish-id.d.ts +5 -0
- package/build/cli/util/publish-id.d.ts.map +1 -0
- package/build/cli/util/publish-id.js +26 -0
- package/build/constants/compression.d.ts +3 -0
- package/build/constants/compression.d.ts.map +1 -0
- package/build/constants/compression.js +4 -0
- package/build/index.d.ts +5 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -1
- package/build/presets/implementations/create-react-app.js +1 -2
- package/build/presets/preset-base.d.ts +1 -1
- package/build/presets/preset-base.d.ts.map +1 -1
- package/build/server/assets/asset-manager.d.ts +7 -0
- package/build/server/assets/asset-manager.d.ts.map +1 -0
- package/build/server/assets/asset-manager.js +11 -0
- package/build/server/assets/content-assets.d.ts +33 -0
- package/build/server/assets/content-assets.d.ts.map +1 -0
- package/build/server/assets/content-assets.js +135 -0
- package/build/server/assets/module-assets.d.ts +23 -0
- package/build/server/assets/module-assets.d.ts.map +1 -0
- package/build/server/assets/module-assets.js +45 -0
- package/build/server/object-store/include-bytes-store-entry.d.ts +19 -0
- package/build/server/object-store/include-bytes-store-entry.d.ts.map +1 -0
- package/build/server/object-store/include-bytes-store-entry.js +87 -0
- package/build/server/object-store/inline-store-entry.d.ts +23 -0
- package/build/server/object-store/inline-store-entry.d.ts.map +1 -0
- package/build/server/object-store/inline-store-entry.js +95 -0
- package/build/server/publisher-server.d.ts +23 -0
- package/build/server/publisher-server.d.ts.map +1 -0
- package/build/server/publisher-server.js +224 -0
- package/build/server/serve-preconditions/if-modified-since.d.ts +4 -0
- package/build/server/serve-preconditions/if-modified-since.d.ts.map +1 -0
- package/build/server/serve-preconditions/if-modified-since.js +26 -0
- package/build/server/serve-preconditions/if-none-match.d.ts +3 -0
- package/build/server/serve-preconditions/if-none-match.d.ts.map +1 -0
- package/build/server/serve-preconditions/if-none-match.js +24 -0
- package/build/server/util/http.d.ts +2 -0
- package/build/server/util/http.d.ts.map +1 -0
- package/build/server/util/http.js +9 -0
- package/build/types/compute.d.ts +10 -0
- package/build/types/compute.d.ts.map +1 -0
- package/build/types/compute.js +1 -0
- package/build/types/config-normalized.d.ts +33 -0
- package/build/types/config-normalized.d.ts.map +1 -0
- package/build/types/config-normalized.js +1 -0
- package/build/types/config.d.ts +36 -0
- package/build/types/config.d.ts.map +1 -0
- package/build/types/config.js +1 -0
- package/build/types/content-assets.d.ts +37 -0
- package/build/types/content-assets.d.ts.map +1 -0
- package/build/types/content-assets.js +1 -0
- package/build/types/content-types.d.ts +11 -0
- package/build/types/content-types.d.ts.map +1 -0
- package/build/types/content-types.js +1 -0
- package/build/types/index.d.ts +7 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +1 -0
- package/build/types/module-assets.d.ts +15 -0
- package/build/types/module-assets.d.ts.map +1 -0
- package/build/types/module-assets.js +1 -0
- package/build/types/util.d.ts +7 -0
- package/build/types/util.d.ts.map +1 -0
- package/build/types/util.js +1 -0
- package/build/util/content-types.d.ts +5 -0
- package/build/util/content-types.d.ts.map +1 -0
- package/build/util/content-types.js +92 -0
- package/build/util/data.d.ts +7 -0
- package/build/util/data.d.ts.map +1 -0
- package/build/util/data.js +58 -0
- package/build/util/fastly-api.d.ts +10 -0
- package/build/util/fastly-api.d.ts.map +1 -0
- package/build/util/fastly-api.js +47 -0
- package/build/util/files.d.ts +10 -0
- package/build/util/files.d.ts.map +1 -0
- package/build/util/files.js +32 -0
- package/build/util/hash.d.ts +2 -0
- package/build/util/hash.d.ts.map +1 -0
- package/build/util/hash.js +8 -0
- package/build/util/id.d.ts +3 -0
- package/build/util/id.d.ts.map +1 -0
- package/build/util/id.js +17 -0
- package/build/util/index.d.ts +3 -0
- package/build/util/index.d.ts.map +1 -0
- package/build/util/index.js +2 -0
- package/build/util/metadata.d.ts +3 -0
- package/build/util/metadata.d.ts.map +1 -0
- package/build/util/metadata.js +12 -0
- package/build/util/object-store.d.ts +12 -0
- package/build/util/object-store.d.ts.map +1 -0
- package/build/util/object-store.js +80 -0
- package/package.json +10 -5
- package/resources/index.js +9 -114
- package/resources/statics-metadata.d.ts +10 -0
- package/resources/statics.d.ts +15 -7
- package/resources/webpack.config.js +4 -10
- package/build/assets.d.ts +0 -8
- package/build/assets.d.ts.map +0 -1
- package/build/assets.js +0 -24
- package/build/build-static.d.ts.map +0 -1
- package/build/build-static.js +0 -249
- package/build/cli.d.ts.map +0 -1
- package/build/init-app.d.ts.map +0 -1
- package/build/static-assets.d.ts +0 -11
- package/build/static-assets.d.ts.map +0 -1
- package/build/static-assets.js +0 -33
- package/build/types.d.ts +0 -50
- package/build/types.d.ts.map +0 -1
- package/resources/default-content-types.cjs +0 -106
- package/resources/default-content-types.d.ts +0 -15
- /package/build/{build-static.d.ts → cli/build-static.d.ts} +0 -0
- /package/build/{content-types.js → cli/clean-object-store.js} +0 -0
- /package/build/{cli.d.ts → cli/cli.d.ts} +0 -0
- /package/build/{init-app.d.ts → cli/commands/init-app.d.ts} +0 -0
- /package/build/{types.js → cli/presets/preset-base.js} +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const defaultContentTypes = [
|
|
2
|
+
// Text formats
|
|
3
|
+
{ test: /.txt$/, contentType: 'text/plain', text: true },
|
|
4
|
+
{ test: /.htm(l)?$/, contentType: 'text/html', text: true },
|
|
5
|
+
{ test: /.xml$/, contentType: 'application/xml', text: true },
|
|
6
|
+
{ test: /.json$/, contentType: 'application/json', text: true },
|
|
7
|
+
{ test: /.map$/, contentType: 'application/json', text: true },
|
|
8
|
+
{ test: /.js$/, contentType: 'application/javascript', text: true },
|
|
9
|
+
{ test: /.css$/, contentType: 'text/css', text: true },
|
|
10
|
+
{ test: /.svg$/, contentType: 'image/svg+xml', text: true },
|
|
11
|
+
// Binary formats
|
|
12
|
+
{ test: /.bmp$/, contentType: 'image/bmp', text: false },
|
|
13
|
+
{ test: /.png$/, contentType: 'image/png', text: false },
|
|
14
|
+
{ test: /.gif$/, contentType: 'image/gif', text: false },
|
|
15
|
+
{ test: /.jp(e)?g$/, contentType: 'image/jpeg', text: false },
|
|
16
|
+
{ test: /.ico$/, contentType: 'image/vnd.microsoft.icon', text: false },
|
|
17
|
+
{ test: /.tif(f)?$/, contentType: 'image/png', text: false },
|
|
18
|
+
{ test: /.aac$/, contentType: 'audio/aac', text: false },
|
|
19
|
+
{ test: /.mp3$/, contentType: 'audio/mpeg', text: false },
|
|
20
|
+
{ test: /.avi$/, contentType: 'video/x-msvideo', text: false },
|
|
21
|
+
{ test: /.mp4$/, contentType: 'video/mp4', text: false },
|
|
22
|
+
{ test: /.mpeg$/, contentType: 'video/mpeg', text: false },
|
|
23
|
+
{ test: /.webm$/, contentType: 'video/webm', text: false },
|
|
24
|
+
{ test: /.pdf$/, contentType: 'application/pdf', text: false },
|
|
25
|
+
{ test: /.tar$/, contentType: 'application/x-tar', text: false },
|
|
26
|
+
{ test: /.zip$/, contentType: 'application/zip', text: false },
|
|
27
|
+
{ test: /.eot$/, contentType: 'application/vnd.ms-fontobject', text: false },
|
|
28
|
+
{ test: /.otf$/, contentType: 'font/otf', text: false },
|
|
29
|
+
{ test: /.ttf$/, contentType: 'font/ttf', text: false },
|
|
30
|
+
{ test: /.woff$/, contentType: 'font/woff', text: false },
|
|
31
|
+
{ test: /.woff2$/, contentType: 'font/woff2', text: false },
|
|
32
|
+
];
|
|
33
|
+
export function getDefaultContentTypes() {
|
|
34
|
+
return defaultContentTypes;
|
|
35
|
+
}
|
|
36
|
+
export function mergeContentTypes(contentTypes) {
|
|
37
|
+
const finalContentTypes = [];
|
|
38
|
+
if (!Array.isArray(contentTypes)) {
|
|
39
|
+
console.warn('contentTypes not an array, ignoring.');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
for (const [index, contentType] of contentTypes.entries()) {
|
|
43
|
+
let invalid = false;
|
|
44
|
+
if (typeof contentType.test !== 'function' &&
|
|
45
|
+
!(contentType.test instanceof RegExp)) {
|
|
46
|
+
console.log(`⚠️ Ignoring contentTypes[${index}]: 'test' must be a function or regular expression.`);
|
|
47
|
+
invalid = true;
|
|
48
|
+
}
|
|
49
|
+
if (typeof contentType.contentType !== 'string' || contentType.contentType.indexOf('/') === -1) {
|
|
50
|
+
console.log(`⚠️ Ignoring contentTypes[${index}]: 'type' must be a string representing a MIME type.`);
|
|
51
|
+
invalid = true;
|
|
52
|
+
}
|
|
53
|
+
if ('text' in contentType && typeof contentType.text !== 'boolean') {
|
|
54
|
+
console.log(`⚠️ Ignoring contentTypes[${index}]: optional 'text' must be a boolean value.`);
|
|
55
|
+
invalid = true;
|
|
56
|
+
}
|
|
57
|
+
if (!invalid) {
|
|
58
|
+
const contentTypeDef = {
|
|
59
|
+
test: contentType.test,
|
|
60
|
+
contentType: contentType.contentType,
|
|
61
|
+
};
|
|
62
|
+
if (contentType.text != null) {
|
|
63
|
+
contentTypeDef.text = contentType.text;
|
|
64
|
+
}
|
|
65
|
+
finalContentTypes.push(contentTypeDef);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
console.log('✔️ Applying ' + finalContentTypes.length + ' custom content type(s).');
|
|
70
|
+
// NOTE: these come later because these are tested in order.
|
|
71
|
+
// In other words, the earlier ones have higher precedence.
|
|
72
|
+
for (const contentType of defaultContentTypes) {
|
|
73
|
+
finalContentTypes.push(contentType);
|
|
74
|
+
}
|
|
75
|
+
return finalContentTypes;
|
|
76
|
+
}
|
|
77
|
+
export function testFileContentType(contentTypes, assetKey) {
|
|
78
|
+
for (const contentType of contentTypes ?? defaultContentTypes) {
|
|
79
|
+
let matched = false;
|
|
80
|
+
if (contentType.test instanceof RegExp) {
|
|
81
|
+
matched = contentType.test.test(assetKey);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// should be a function
|
|
85
|
+
matched = contentType.test(assetKey);
|
|
86
|
+
}
|
|
87
|
+
if (matched) {
|
|
88
|
+
return { contentType: contentType.contentType, text: Boolean(contentType.text ?? false) };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type NormalizeAction<T> = (value: any, errors: string[]) => T | null;
|
|
2
|
+
export declare function buildNormalizeFunctionForObject<TObject>(action: NormalizeAction<TObject>): (obj: any, errCtx?: string[]) => TObject | null;
|
|
3
|
+
export declare function buildNormalizeFunctionForArray<TEntry>(action: NormalizeAction<TEntry>): (obj: any, errCtx?: string[]) => TEntry[] | null;
|
|
4
|
+
export declare function isStringAndNotEmpty(str: unknown): str is string;
|
|
5
|
+
export declare function isSpecified(obj: any, key: string): boolean;
|
|
6
|
+
export declare function applyDefaults<T extends Record<string, unknown>>(data: Partial<T> | null, defaults: T): T & Partial<T>;
|
|
7
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/util/data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;AAE5E,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,SAE1E,GAAG,WAAU,MAAM,EAAE,KAAQ,OAAO,GAAG,IAAI,CAmBzD;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,SAEvE,GAAG,WAAU,MAAM,EAAE,KAAQ,MAAM,EAAE,GAAG,IAAI,CAgC1D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAE/D;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAC,GAAG,EAAE,GAAG,EAAE,MAAM,WAE/C;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,kBAYpG"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function buildNormalizeFunctionForObject(action) {
|
|
2
|
+
return (obj, errCtx = []) => {
|
|
3
|
+
if (obj == null) {
|
|
4
|
+
errCtx.push('obj cannot be null.');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const errors = [];
|
|
8
|
+
const normalizedObj = action(obj, errors);
|
|
9
|
+
for (const error of errors) {
|
|
10
|
+
errCtx.push(error);
|
|
11
|
+
}
|
|
12
|
+
return normalizedObj;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function buildNormalizeFunctionForArray(action) {
|
|
16
|
+
return (obj, errCtx = []) => {
|
|
17
|
+
if (!Array.isArray(obj)) {
|
|
18
|
+
errCtx.push('obj must be array.');
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const errors = [];
|
|
22
|
+
let normalizedEntries = [];
|
|
23
|
+
for (const [index, entry] of obj.entries()) {
|
|
24
|
+
const innerErrors = [];
|
|
25
|
+
const normalizedEntry = action(entry, innerErrors);
|
|
26
|
+
if (normalizedEntry != null) {
|
|
27
|
+
normalizedEntries.push(normalizedEntry);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
errors.push(`Item [${index + 1}]:`);
|
|
31
|
+
errors.push(...innerErrors);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (errors.length > 0) {
|
|
35
|
+
normalizedEntries = null;
|
|
36
|
+
}
|
|
37
|
+
for (const error of errors) {
|
|
38
|
+
errCtx.push(error);
|
|
39
|
+
}
|
|
40
|
+
return normalizedEntries;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function isStringAndNotEmpty(str) {
|
|
44
|
+
return typeof str === 'string' && str !== '';
|
|
45
|
+
}
|
|
46
|
+
export function isSpecified(obj, key) {
|
|
47
|
+
return key in obj;
|
|
48
|
+
}
|
|
49
|
+
export function applyDefaults(data, defaults) {
|
|
50
|
+
// Remove undefined values
|
|
51
|
+
const temp = Object.assign({}, data);
|
|
52
|
+
for (const [key, value] of Object.entries(temp)) {
|
|
53
|
+
if (value === undefined) {
|
|
54
|
+
delete temp[key];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return Object.assign({}, defaults, temp);
|
|
58
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface FastlyApiContext {
|
|
2
|
+
apiToken: string;
|
|
3
|
+
}
|
|
4
|
+
export type LoadApiKeyResult = {
|
|
5
|
+
apiToken: string;
|
|
6
|
+
source: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function loadApiKey(): LoadApiKeyResult | null;
|
|
9
|
+
export declare function callFastlyApi(fastlyApiContext: FastlyApiContext, endpoint: string, queryParams?: URLSearchParams | null, requestInit?: RequestInit): Promise<Response>;
|
|
10
|
+
//# sourceMappingURL=fastly-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fastly-api.d.ts","sourceRoot":"","sources":["../../src/util/fastly-api.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,UAAU,IAAI,gBAAgB,GAAG,IAAI,CA+BpD;AAED,wBAAsB,aAAa,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,eAAe,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsB5K"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
;
|
|
3
|
+
export function loadApiKey() {
|
|
4
|
+
let apiToken = null;
|
|
5
|
+
let source = '';
|
|
6
|
+
// Try to get API key from FASTLY_API_TOKEN
|
|
7
|
+
apiToken = process.env.FASTLY_API_TOKEN || null;
|
|
8
|
+
if (apiToken != null) {
|
|
9
|
+
source = 'env';
|
|
10
|
+
}
|
|
11
|
+
if (apiToken == null) {
|
|
12
|
+
// Try to get API key from fastly cli
|
|
13
|
+
try {
|
|
14
|
+
apiToken = execSync('fastly profile token', {
|
|
15
|
+
encoding: 'utf-8',
|
|
16
|
+
}) || null;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
apiToken = null;
|
|
20
|
+
}
|
|
21
|
+
if (apiToken != null) {
|
|
22
|
+
source = 'fastly-profile-token';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (apiToken == null) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return { apiToken, source };
|
|
29
|
+
}
|
|
30
|
+
export async function callFastlyApi(fastlyApiContext, endpoint, queryParams, requestInit) {
|
|
31
|
+
let finalEndpoint = endpoint;
|
|
32
|
+
if (queryParams != null) {
|
|
33
|
+
const queryString = String(queryParams);
|
|
34
|
+
if (queryString.length > 0) {
|
|
35
|
+
finalEndpoint += '?' + queryString;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const url = new URL(finalEndpoint, 'https://api.fastly.com/');
|
|
39
|
+
const headers = new Headers(requestInit?.headers);
|
|
40
|
+
headers.set('Fastly-Key', fastlyApiContext.apiToken);
|
|
41
|
+
const request = new Request(url, {
|
|
42
|
+
...requestInit,
|
|
43
|
+
headers,
|
|
44
|
+
});
|
|
45
|
+
const response = await fetch(request);
|
|
46
|
+
return response;
|
|
47
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface FilenameTest {
|
|
2
|
+
test(name: string): boolean;
|
|
3
|
+
}
|
|
4
|
+
export type GetFilesOpts = {
|
|
5
|
+
excludeDirs: FilenameTest[];
|
|
6
|
+
excludeDotFiles: boolean;
|
|
7
|
+
includeWellKnown: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function getFiles(dir: string, opts: GetFilesOpts): string[];
|
|
10
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/util/files.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,YAAY,EAAE,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,YAIvD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
export function getFiles(dir, opts) {
|
|
4
|
+
const results = [];
|
|
5
|
+
getFilesWorker(results, dir, opts);
|
|
6
|
+
return results;
|
|
7
|
+
}
|
|
8
|
+
function getFilesWorker(results, dir, opts) {
|
|
9
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
10
|
+
for (const entry of entries) {
|
|
11
|
+
const { name } = entry;
|
|
12
|
+
const { excludeDirs, excludeDotFiles, includeWellKnown, } = opts;
|
|
13
|
+
if (excludeDirs.some(excludeDir => excludeDir.test(name))) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (excludeDotFiles && name.startsWith('.')) {
|
|
17
|
+
if (includeWellKnown && name === '.well-known') {
|
|
18
|
+
// ok
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const fullpath = path.resolve(dir, name);
|
|
25
|
+
if (entry.isDirectory()) {
|
|
26
|
+
getFilesWorker(results, fullpath, opts);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
results.push(fullpath);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/util/hash.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,UASjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/util/id.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,WAE7B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,UAYxC"}
|
package/build/util/id.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
const ID_SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
3
|
+
const ID_SYMBOLS_BASE = BigInt(ID_SYMBOLS.length);
|
|
4
|
+
export function createStringId() {
|
|
5
|
+
return uuidToString(crypto.randomUUID());
|
|
6
|
+
}
|
|
7
|
+
export function uuidToString(uuid) {
|
|
8
|
+
const uuidWithoutHyphens = uuid.replace(/-/g, '');
|
|
9
|
+
let number = BigInt('0x' + uuidWithoutHyphens);
|
|
10
|
+
let result = '';
|
|
11
|
+
do {
|
|
12
|
+
const [quotient, remainder] = [number / ID_SYMBOLS_BASE, Number(number % ID_SYMBOLS_BASE)];
|
|
13
|
+
result = ID_SYMBOLS.charAt(remainder) + result;
|
|
14
|
+
number = quotient;
|
|
15
|
+
} while (number > 0n);
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/util/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,wBAAgB,8BAA8B,CAAC,uBAAuB,EAAE,uBAAuB,GAAG,GAAG,CAAC,MAAM,CAAC,CAe5G"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function getObjectStoreKeysFromMetadata(contentAssetMetadataMap) {
|
|
2
|
+
const results = new Set();
|
|
3
|
+
for (const metadata of Object.values(contentAssetMetadataMap)) {
|
|
4
|
+
if (!metadata.isInline) {
|
|
5
|
+
results.add(metadata.fileInfo.objectStoreKey);
|
|
6
|
+
for (const fileInfo of Object.values(metadata.compressedFileInfos)) {
|
|
7
|
+
results.add(fileInfo.objectStoreKey);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return results;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FastlyApiContext } from "./fastly-api.js";
|
|
2
|
+
export declare function getObjectStoreIdForNameMap(fastlyApiContext: FastlyApiContext): Promise<Record<string, string>>;
|
|
3
|
+
export declare function getObjectStoreIdForName(fastlyApiContext: FastlyApiContext, objectStoreName: string): Promise<string | null>;
|
|
4
|
+
type ObjectStoreInfo = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function getObjectStoreInfos(fastlyApiContext: FastlyApiContext): Promise<ObjectStoreInfo[]>;
|
|
9
|
+
export declare function objectStoreEntryExists(fastlyApiContext: FastlyApiContext, objectStoreName: string, key: string): Promise<boolean>;
|
|
10
|
+
export declare function objectStoreSubmitFile(fastlyApiContext: FastlyApiContext, objectStoreName: string, key: string, data: Uint8Array | string): Promise<void>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=object-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../../src/util/object-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AASlE,wBAAsB,0BAA0B,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkBpH;AAED,wBAAsB,uBAAuB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIjI;AAGD,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAWF,wBAAsB,mBAAmB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAwCxG;AAGD,wBAAsB,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAavI;AAGD,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB9J"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { callFastlyApi } from "./fastly-api.js";
|
|
2
|
+
const cache = new WeakMap();
|
|
3
|
+
export async function getObjectStoreIdForNameMap(fastlyApiContext) {
|
|
4
|
+
const cacheEntry = cache.get(fastlyApiContext);
|
|
5
|
+
let objectStoreNameMap = cacheEntry?.objectStoreNameMap;
|
|
6
|
+
if (objectStoreNameMap != null) {
|
|
7
|
+
return objectStoreNameMap;
|
|
8
|
+
}
|
|
9
|
+
const objectStoreInfos = await getObjectStoreInfos(fastlyApiContext);
|
|
10
|
+
objectStoreNameMap = {};
|
|
11
|
+
for (const { id, name } of objectStoreInfos) {
|
|
12
|
+
objectStoreNameMap[name] = id;
|
|
13
|
+
}
|
|
14
|
+
cache.set(fastlyApiContext, { ...cacheEntry, objectStoreNameMap });
|
|
15
|
+
return objectStoreNameMap;
|
|
16
|
+
}
|
|
17
|
+
export async function getObjectStoreIdForName(fastlyApiContext, objectStoreName) {
|
|
18
|
+
const objectStoreNameMap = await getObjectStoreIdForNameMap(fastlyApiContext);
|
|
19
|
+
return objectStoreNameMap[objectStoreName] ?? null;
|
|
20
|
+
}
|
|
21
|
+
// Cache this globally. We don't expect it to change during one run of this app.
|
|
22
|
+
let _objectStoreInfos = undefined;
|
|
23
|
+
export async function getObjectStoreInfos(fastlyApiContext) {
|
|
24
|
+
const cacheEntry = cache.get(fastlyApiContext);
|
|
25
|
+
let objectStoreInfos = cacheEntry?.objectStoreInfos;
|
|
26
|
+
if (objectStoreInfos != null) {
|
|
27
|
+
return objectStoreInfos;
|
|
28
|
+
}
|
|
29
|
+
objectStoreInfos = [];
|
|
30
|
+
let cursor = null;
|
|
31
|
+
while (true) {
|
|
32
|
+
let endpoint = `/resources/stores/object`;
|
|
33
|
+
const queryParams = new URLSearchParams();
|
|
34
|
+
if (cursor != null) {
|
|
35
|
+
queryParams.set('cursor', cursor);
|
|
36
|
+
}
|
|
37
|
+
const response = await callFastlyApi(fastlyApiContext, endpoint, queryParams);
|
|
38
|
+
if (response.status !== 200) {
|
|
39
|
+
throw new Error('Unexpected data format');
|
|
40
|
+
}
|
|
41
|
+
const infos = await response.json();
|
|
42
|
+
for (const item of infos.data) {
|
|
43
|
+
objectStoreInfos.push(item);
|
|
44
|
+
}
|
|
45
|
+
if (infos.meta.next_cursor === undefined) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
cursor = infos.meta.next_cursor;
|
|
49
|
+
}
|
|
50
|
+
cache.set(fastlyApiContext, { ...cacheEntry, objectStoreInfos });
|
|
51
|
+
return objectStoreInfos;
|
|
52
|
+
}
|
|
53
|
+
export async function objectStoreEntryExists(fastlyApiContext, objectStoreName, key) {
|
|
54
|
+
const objectStoreId = await getObjectStoreIdForName(fastlyApiContext, objectStoreName);
|
|
55
|
+
if (objectStoreId == null) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const endpoint = `/resources/stores/object/${encodeURIComponent(objectStoreId)}/keys/${encodeURIComponent(key)}`;
|
|
59
|
+
const response = await callFastlyApi(fastlyApiContext, endpoint, null, { method: 'HEAD' });
|
|
60
|
+
return response.status === 200;
|
|
61
|
+
}
|
|
62
|
+
const encoder = new TextEncoder();
|
|
63
|
+
export async function objectStoreSubmitFile(fastlyApiContext, objectStoreName, key, data) {
|
|
64
|
+
const objectStoreId = await getObjectStoreIdForName(fastlyApiContext, objectStoreName);
|
|
65
|
+
if (objectStoreId == null) {
|
|
66
|
+
throw new Error('Object store not found');
|
|
67
|
+
}
|
|
68
|
+
const endpoint = `/resources/stores/object/${encodeURIComponent(objectStoreId)}/keys/${encodeURIComponent(key)}`;
|
|
69
|
+
const body = typeof data === 'string' ? encoder.encode(data) : data;
|
|
70
|
+
const response = await callFastlyApi(fastlyApiContext, endpoint, null, {
|
|
71
|
+
method: 'PUT',
|
|
72
|
+
headers: {
|
|
73
|
+
'content-type': 'application/octet-stream',
|
|
74
|
+
},
|
|
75
|
+
body,
|
|
76
|
+
});
|
|
77
|
+
if (response.status !== 200) {
|
|
78
|
+
throw new Error(`Submitting item ${key} gave error: ${response.status}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastly/compute-js-static-publish",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0-alpha.0",
|
|
5
5
|
"description": "Static Publisher for Compute@Edge JavaScript",
|
|
6
6
|
"main": "./build/index.js",
|
|
7
7
|
"types": "./build/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
+
"clean": "rimraf build",
|
|
9
10
|
"prepack": "npm run build",
|
|
10
11
|
"build": "tsc",
|
|
11
12
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
13
|
},
|
|
13
14
|
"bin": {
|
|
14
|
-
"compute-js-static-publish": "./build/cli.js"
|
|
15
|
+
"compute-js-static-publish": "./build/cli/index.js"
|
|
15
16
|
},
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|
|
@@ -31,15 +32,19 @@
|
|
|
31
32
|
"homepage": "https://github.com/fastly/compute-js-static-publish#readme",
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@fastly/js-compute": "^1.4.0",
|
|
34
|
-
"
|
|
35
|
+
"brotli-compress": "^1.3.3",
|
|
36
|
+
"command-line-args": "^5.2.1",
|
|
37
|
+
"glob-to-regexp": "^0.4.1"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
40
|
"@types/command-line-args": "^5.2.0",
|
|
41
|
+
"@types/glob-to-regexp": "^0.4.1",
|
|
38
42
|
"@types/node": "^18.0.0",
|
|
39
|
-
"
|
|
43
|
+
"rimraf": "^4.3.0",
|
|
44
|
+
"typescript": "^4.9.5"
|
|
40
45
|
},
|
|
41
46
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
47
|
+
"node": ">=18"
|
|
43
48
|
},
|
|
44
49
|
"files": [
|
|
45
50
|
"build",
|
package/resources/index.js
CHANGED
|
@@ -1,122 +1,17 @@
|
|
|
1
1
|
/// <reference types="@fastly/js-compute" />
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { getServer } from './statics.js';
|
|
4
|
+
const server = getServer();
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// eslint-disable-next-line no-restricted-globals
|
|
7
|
+
addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
|
|
8
|
+
async function handleRequest(event) {
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
const response = await server.serveRequest(event.request);
|
|
9
11
|
|
|
10
|
-
if(
|
|
11
|
-
|
|
12
|
-
if (staticAssets.getAsset(path) != null) {
|
|
13
|
-
return path;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// ... or, we can try auto-ext:
|
|
17
|
-
// looks for an asset that has the specified suffix (usually extension, such as .html)
|
|
18
|
-
if(Array.isArray(autoExt)) {
|
|
19
|
-
for (const extEntry of autoExt) {
|
|
20
|
-
let pathWithExt = path + extEntry;
|
|
21
|
-
if (staticAssets.getAsset(pathWithExt) != null) {
|
|
22
|
-
return pathWithExt;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// try auto-index:
|
|
29
|
-
// treats the path as a directory, and looks for an asset with the specified
|
|
30
|
-
// suffix (usually an index file, such as index.html)
|
|
31
|
-
let dir = path;
|
|
32
|
-
// remove all slashes from end, and add one trailing slash
|
|
33
|
-
while(dir.endsWith('/')) {
|
|
34
|
-
dir = dir.slice(0, -1);
|
|
12
|
+
if (response != null) {
|
|
13
|
+
return response;
|
|
35
14
|
}
|
|
36
|
-
dir = dir + '/';
|
|
37
|
-
if(Array.isArray(autoIndex)) {
|
|
38
|
-
for (const indexEntry of autoIndex) {
|
|
39
|
-
let indexPath = dir + indexEntry;
|
|
40
|
-
if (staticAssets.getAsset(indexPath) != null) {
|
|
41
|
-
return indexPath;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
15
|
|
|
49
|
-
|
|
50
|
-
const accept = (req.headers.get('Accept') ?? '')
|
|
51
|
-
.split(',')
|
|
52
|
-
.map(x => x.split(';')[0]);
|
|
53
|
-
if(!accept.includes('text/html') && !accept.includes('*/*') && accept.includes('*')) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
return true;
|
|
16
|
+
return new Response('Not found', { status: 404 });
|
|
57
17
|
}
|
|
58
|
-
|
|
59
|
-
router.get("*", (req, res) => {
|
|
60
|
-
const assetPath = getMatchingRequestPath(req.urlObj.pathname);
|
|
61
|
-
const asset = staticAssets.getAsset(assetPath);
|
|
62
|
-
if(asset == null) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const response = staticAssets.serveAsset(asset);
|
|
67
|
-
res.send(response);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// TODO: If you need to handle any API routes, add them here.
|
|
71
|
-
// router.get("/api/endpoint", (req, res) => {
|
|
72
|
-
// res.send("foo");
|
|
73
|
-
// });
|
|
74
|
-
|
|
75
|
-
// If this is a SPA, then return index.html for HTML requests
|
|
76
|
-
router.get("*", (req, res) => {
|
|
77
|
-
if(!spaFile) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if(!requestAcceptsTextHtml(req)) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const asset = staticAssets.getAsset(spaFile);
|
|
84
|
-
if(asset == null) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const response = new Response(asset.content, {
|
|
89
|
-
status: 200,
|
|
90
|
-
headers: {
|
|
91
|
-
'Cache-Control': 'no-cache',
|
|
92
|
-
'Content-Type': 'text/html',
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
res.send(response);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
router.all("*", (req, res) => {
|
|
99
|
-
if(notFoundPageFile && requestAcceptsTextHtml(req)) {
|
|
100
|
-
const asset = staticAssets.getAsset(notFoundPageFile);
|
|
101
|
-
if(asset != null) {
|
|
102
|
-
const response = new Response(asset.content, {
|
|
103
|
-
status: 404,
|
|
104
|
-
headers: {
|
|
105
|
-
'Cache-Control': 'no-cache',
|
|
106
|
-
'Content-Type': 'text/html',
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
res.send(response);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
res.send(new Response("404 Not Found", {
|
|
115
|
-
status: 404,
|
|
116
|
-
headers: {
|
|
117
|
-
'Content-Type': 'text/plain',
|
|
118
|
-
},
|
|
119
|
-
}));
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
router.listen();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Generated by @fastly/compute-js-static-publish.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
ContentAssetMetadataMap,
|
|
7
|
+
} from "@fastly/compute-js-static-publish";
|
|
8
|
+
|
|
9
|
+
export declare const objectStoreName: string | null;
|
|
10
|
+
export declare const contentAssetMetadataMap: ContentAssetMetadataMap;
|