Closed
Description
Describe the problem
Endpoints need to have access to user session to perform actions. Right now, you have to reimplement/import session management in endpoints.
Describe the proposed solution
Why not just expose session
as part of Request
to endpoints. We are already running getSession
for pages. Let's run it for endpoints as well and have the results available in RequestEvent
to endpoint handlers. e.g.
export const get: RequestHandler = async function({ url, session }) {
if (!session.username) {
status: 401,
body: { error: "Unauthorized" }
}
return {
body: { message: "ok" },
};
};
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels