Skip to content

Commit

Permalink
sveltekit 270 & One liner fix (#890)
Browse files Browse the repository at this point in the history
* 🐛 FIX: sveltekit config breaking change

* 🐛 FIX: sveltekit one liner fix
  • Loading branch information
jycouet authored Feb 16, 2022
1 parent bdf08ed commit b4d451a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 8 additions & 2 deletions examples/sveltekit/src/routes/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ const yogaApp = createServer({
}
});

function requestEventHandler(event: RequestEvent): Promise<Response> {
return yogaApp.handleRequest(event.request);
async function requestEventHandler(event: RequestEvent) {
const response = await yogaApp.handleRequest(event.request);

return {
status: response.status,
headers: new Headers(response.headers),
body: await response.text()
};
}

export { requestEventHandler as get, requestEventHandler as post };
7 changes: 1 addition & 6 deletions examples/sveltekit/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),

kit: {
adapter: adapter(),

// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte'
adapter: adapter()
}
};

Expand Down
10 changes: 8 additions & 2 deletions website/docs/integrations/integration-with-sveltekit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ const yogaApp = createServer({
},
})

function requestEventHandler(event: RequestEvent): Promise<Response> {
return yogaApp.handleRequest(event.request)
async function requestEventHandler(event: RequestEvent) {
const response = await yogaApp.handleRequest(event.request)

return {
status: response.status,
headers: new Headers(response.headers),
body: await response.text(),
}
}

export { requestEventHandler as get, requestEventHandler as post }
Expand Down

0 comments on commit b4d451a

Please sign in to comment.