diff --git a/packages/adapter/package.json b/packages/adapter/package.json index c1bd7cc..dc9e7ae 100644 --- a/packages/adapter/package.json +++ b/packages/adapter/package.json @@ -24,11 +24,12 @@ ], "author": "juhani@juranki.com", "devDependencies": { - "@sveltejs/kit": "1.0.0-next.348", + "@sveltejs/kit": "1.0.0-next.428", "@types/aws-lambda": "^8.10.98", "@types/node": "17.0.39", "rimraf": "^3.0.2", - "typescript": "^4.7.3" + "typescript": "^4.7.3", + "node-fetch": "^3.2.10" }, "dependencies": { "esbuild": "^0.14.42" diff --git a/packages/adapter/src/files/ambient.d.ts b/packages/adapter/src/files/ambient.d.ts new file mode 100644 index 0000000..3b00e9e --- /dev/null +++ b/packages/adapter/src/files/ambient.d.ts @@ -0,0 +1,4 @@ +export { } +declare global { + export { Request,HeadersInit, Response, Headers } from 'node-fetch' +} \ No newline at end of file diff --git a/packages/adapter/src/files/at-edge-handler.ts b/packages/adapter/src/files/at-edge-handler.ts index e0f5b4e..f8c8874 100644 --- a/packages/adapter/src/files/at-edge-handler.ts +++ b/packages/adapter/src/files/at-edge-handler.ts @@ -138,7 +138,7 @@ async function transformResponse(rendered: Response): Promise { + headers.forEach((v: string, k: string) => { if (isBlaclisted(k.toLowerCase())) return rv[k.toLowerCase()] = [{ key: k, diff --git a/packages/adapter/src/files/util.ts b/packages/adapter/src/files/util.ts index 6cbe8d2..b386a5a 100644 --- a/packages/adapter/src/files/util.ts +++ b/packages/adapter/src/files/util.ts @@ -21,7 +21,7 @@ export interface BodyInfo { encoding: 'base64' | 'text' } -export function toRawBody(body: BodyInfo): BodyInit { +export function toRawBody(body: BodyInfo): Buffer | string { return body.encoding === 'base64' ? Buffer.from(body.data, 'base64') : body.data diff --git a/packages/adapter/src/index.ts b/packages/adapter/src/index.ts index 7c06af6..f11e923 100644 --- a/packages/adapter/src/index.ts +++ b/packages/adapter/src/index.ts @@ -65,7 +65,6 @@ export function adapter({ const prerendered = builder.writePrerendered(dirs.prerendered) const clientfiles = builder.writeClient(dirs.static) - const staticfiles = builder.writeStatic(dirs.static) // get the routes of prerendered pages const prerenderedRoutes = prerendered.map( @@ -79,17 +78,13 @@ export function adapter({ path.join(targetPath, 'client.json'), `[${clientfiles.map(p => `"${p}"`).join(',')}]` ) - writeFileSync( - path.join(targetPath, 'static.json'), - `[${staticfiles.map(p => `"${p}"`).join(',')}]` - ) writeFileSync( path.join(targetPath, 'headers.json'), `[${(headers || ['accept']).map(h => `"${h.toLowerCase()}"`).join(',')}]` ) writeRoutes( path.join(targetPath, 'routes.json'), - prerendered, staticfiles, clientfiles + prerendered, clientfiles ) mkdirSync(builder.getBuildDirectory('cdk'), { recursive: true }) const copiedFiles = builder.copy(files, builder.getBuildDirectory('cdk'), { @@ -115,10 +110,10 @@ export function adapter({ } } export type StaticRoutes = Record -function writeRoutes(path: string, pre: string[], sta: string[], cli: string[]) { +function writeRoutes(path: string, pre: string[], cli: string[]) { const rv: StaticRoutes = {}; - [...sta, ...cli].forEach(p => { + cli.forEach(p => { const ps = p.split('/') const glob = ps.length > 1 ? `${ps[0]}/*` : p rv[glob] = 'static'