Version 1.x.x > 2.x.x
Static Asset Servers
The way Static Asset Manifests are consumed has changed.
The new version allows for multiple manifests within the same application as well as the ability to read file content as a string.
The easiest way for most people to make this migration is to purely re-run:
npx fastedge-init
Unless you have custom written code using these functions, the default static-index.js
should be
updated automatically for you.
Version 1:
import { getStaticServer, createStaticAssetsCache } from '@gcoredev/fastedge-sdk-js';import { staticAssetManifest } from './build/static-server-manifest.js';import { serverConfig } from './build-config.js';
const staticAssets = createStaticAssetsCache(staticAssetManifest);
const staticServer = getStaticServer(serverConfig, staticAssets);
async function handleRequest(event) { const response = await staticServer.serveRequest(event.request); if (response != null) { return response; }
return new Response('Not found', { status: 404 });}
addEventListener('fetch', (event) => event.respondWith(handleRequest(event)));
Version 2:
import { createStaticServer } from '@gcoredev/fastedge-sdk-js';import { staticAssetManifest } from './build/static-asset-manifest.js';import { serverConfig } from './build-config.js';
const staticServer = createStaticServer(staticAssetManifest, serverConfig);
async function handleRequest(event) { const response = await staticServer.serveRequest(event.request); if (response != null) { return response; }
return new Response('Not found', { status: 404 });}
addEventListener('fetch', (event) => event.respondWith(handleRequest(event)));