-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow passing platform context from adapters #3429
Changes from 38 commits
d574cb6
33d4737
56bfe37
8309cd7
bb67019
9f95150
4f4247c
fd9a6f5
df36652
6d34a4c
2d887a3
bcd3c8d
36b139a
eb977ea
a9d3fa9
8745a71
40f8cd7
201e595
0bce46d
e95e1b3
741eda4
19d5039
2f6cb31
c7b10a1
e4a1047
d91beaf
22c2e6f
492809d
e4c7be7
bb2ddaa
e5fd336
4e96cf1
9fc934b
72459fe
54de5bf
d417d00
e68d469
358c747
2a4b54b
9d57b6c
a3121b8
6e90095
9ca9144
5d3c3ae
983ec4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@sveltejs/adapter-cloudflare': patch | ||
'@sveltejs/adapter-node': patch | ||
--- | ||
|
||
Pass `platform` object to SvelteKit | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'create-svelte': patch | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Allow adapters to pass in `platform` object |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,21 +22,22 @@ If unimplemented, defaults to `({ event, resolve }) => resolve(event)`. | |
// everything else must be a type of string | ||
type ResponseHeaders = Record<string, string | string[]>; | ||
|
||
export interface RequestEvent<Locals = Record<string, any>> { | ||
export interface RequestEvent<Locals = Record<string, any>, Platform = Record<string, any>> { | ||
request: Request; | ||
url: URL; | ||
params: Record<string, string>; | ||
locals: Locals; | ||
platform: Platform; | ||
} | ||
|
||
export interface ResolveOpts { | ||
ssr?: boolean; | ||
} | ||
|
||
export interface Handle<Locals = Record<string, any>> { | ||
export interface Handle<Locals = Record<string, any>, Platform = Record<string, any>> { | ||
(input: { | ||
event: RequestEvent<Locals>; | ||
resolve(event: RequestEvent<Locals>, opts?: ResolveOpts): MaybePromise<Response>; | ||
event: RequestEvent<Locals, Platform>; | ||
resolve(event: RequestEvent<Locals, Platform>, opts?: ResolveOpts): MaybePromise<Response>; | ||
}): MaybePromise<Response>; | ||
} | ||
``` | ||
|
@@ -84,8 +85,8 @@ If unimplemented, SvelteKit will log the error with default formatting. | |
|
||
```ts | ||
// Declaration types for handleError hook | ||
export interface HandleError<Locals = Record<string, any>> { | ||
(input: { error: Error & { frame?: string }; event: RequestEvent<Locals> }): void; | ||
export interface HandleError<Locals = Record<string, any>, Platform = Record<string, any>> { | ||
(input: { error: Error & { frame?: string }; event: RequestEvent<Locals, Platform> }): void; | ||
} | ||
``` | ||
|
||
|
@@ -107,8 +108,12 @@ If unimplemented, session is `{}`. | |
|
||
```ts | ||
// Declaration types for getSession hook | ||
export interface GetSession<Locals = Record<string, any>, Session = any> { | ||
(event: RequestEvent<Locals>): Session | Promise<Session>; | ||
export interface GetSession< | ||
Locals = Record<string, any>, | ||
Platform = Record<string, any>, | ||
Session = any | ||
> { | ||
(event: RequestEvent<Locals, Platform>): MaybePromise<Session>; | ||
} | ||
``` | ||
|
||
|
@@ -125,7 +130,7 @@ export function getSession(event) { | |
email: event.locals.user.email, | ||
avatar: event.locals.user.avatar | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be changed back to a tab There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what is causing this one, can't find a setting that would do it. Fixed now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code blocks in markdown files aren't linted. If it's just a regular There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still doesn't look fixed.
fezproof marked this conversation as resolved.
Show resolved
Hide resolved
|
||
: {}; | ||
} | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to say in the changelog what it contains? If so, we're presumably want separate changesets for the Cloudflare and Node adapters.