Skip to content

Commit

Permalink
fix(adapter): update sveltekit and clear errors
Browse files Browse the repository at this point in the history
  • Loading branch information
juranki committed Aug 21, 2022
1 parent 4312dc7 commit fe1772a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions packages/adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
],
"author": "[email protected]",
"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"
Expand Down
4 changes: 4 additions & 0 deletions packages/adapter/src/files/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { }
declare global {
export { Request,HeadersInit, Response, Headers } from 'node-fetch'
}
2 changes: 1 addition & 1 deletion packages/adapter/src/files/at-edge-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async function transformResponse(rendered: Response): Promise<CloudFrontResultRe

function transformOutgoingHeaders(headers: Headers): CloudFrontHeaders {
const rv: CloudFrontHeaders = {}
headers.forEach((v, k) => {
headers.forEach((v: string, k: string) => {
if (isBlaclisted(k.toLowerCase())) return
rv[k.toLowerCase()] = [{
key: k,
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter/src/files/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions packages/adapter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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'), {
Expand All @@ -115,10 +110,10 @@ export function adapter({
}
}
export type StaticRoutes = Record<string, 'prerendered' | 'static'>
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'
Expand Down

0 comments on commit fe1772a

Please sign in to comment.