2023-11-19 13:15:37 +00:00
|
|
|
import type { Handle } from '@sveltejs/kit';
|
|
|
|
|
|
|
|
import { S3_STORAGE_URL } from '$env/static/private';
|
|
|
|
|
|
|
|
import { auth } from '$lib/server/lucia';
|
|
|
|
import { ObjectStorageS3 } from '$lib/server/storage/s3';
|
2023-11-19 17:37:09 +00:00
|
|
|
import { DatabasePrisma } from '$lib/server/db/prisma';
|
2023-11-19 13:15:37 +00:00
|
|
|
|
|
|
|
const s3Client = new ObjectStorageS3(S3_STORAGE_URL);
|
2023-11-19 17:37:09 +00:00
|
|
|
const prismaClient = new DatabasePrisma();
|
2023-11-19 13:15:37 +00:00
|
|
|
|
|
|
|
export const handle: Handle = async ({ event, resolve }) => {
|
|
|
|
event.locals.auth = auth;
|
2023-11-19 17:37:09 +00:00
|
|
|
event.locals.database = prismaClient;
|
2023-11-19 13:15:37 +00:00
|
|
|
event.locals.objectStorage = s3Client;
|
|
|
|
|
|
|
|
event.locals.authReq = auth.handleRequest(event);
|
|
|
|
|
|
|
|
return await resolve(event);
|
|
|
|
};
|