aboutsummaryrefslogtreecommitdiff
path: root/src/hooks.ts
blob: 3fa92998c8b170c75ec3368bc40a0c03fb479eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import cookie from 'cookie'
import type { ExternalFetch, GetSession, Handle } from '@sveltejs/kit'


export const handle: Handle = async ({ event, resolve }) => {
	const cookies = cookie.parse(event.request.headers.get('cookie') || '')

	event.locals.sid = cookies.sid

	const response = await resolve(event)

	return response
}

export const getSession: GetSession = async ({ locals }) => {
	return {
		sid: locals.sid
	}
}

// export const externalFetch: ExternalFetch = async (request) => {
// 	const response = await fetch(request)

// 	return response
// }