fix: Remove all the sever.hooks.ts
This commit is contained in:
parent
73b5556511
commit
62031a36fd
8 changed files with 19 additions and 15 deletions
|
|
@ -42,7 +42,7 @@
|
||||||
"@immich/sdk": "^2.5.6",
|
"@immich/sdk": "^2.5.6",
|
||||||
"@prisma/adapter-better-sqlite3": "^7.4.2",
|
"@prisma/adapter-better-sqlite3": "^7.4.2",
|
||||||
"@prisma/client": "^7.4.2",
|
"@prisma/client": "^7.4.2",
|
||||||
"@sveltejs/adapter-node": "^5.5.3",
|
"@sveltejs/adapter-node": "^5.5.5",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"canvas-dither": "^1.0.1",
|
"canvas-dither": "^1.0.1",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ importers:
|
||||||
specifier: ^7.4.2
|
specifier: ^7.4.2
|
||||||
version: 7.8.0(prisma@7.8.0(@types/react@19.2.17)(better-sqlite3@12.11.1)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(typescript@5.9.3))(typescript@5.9.3)
|
version: 7.8.0(prisma@7.8.0(@types/react@19.2.17)(better-sqlite3@12.11.1)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)(typescript@5.9.3))(typescript@5.9.3)
|
||||||
'@sveltejs/adapter-node':
|
'@sveltejs/adapter-node':
|
||||||
specifier: ^5.5.3
|
specifier: ^5.5.5
|
||||||
version: 5.5.5(@sveltejs/kit@2.66.0(@sveltejs/vite-plugin-svelte@5.1.1(svelte@5.56.3(@typescript-eslint/types@8.61.1))(vite@6.4.3(@types/node@25.9.4)(jiti@2.7.0)(sass@1.101.0)))(svelte@5.56.3(@typescript-eslint/types@8.61.1))(typescript@5.9.3)(vite@6.4.3(@types/node@25.9.4)(jiti@2.7.0)(sass@1.101.0)))
|
version: 5.5.5(@sveltejs/kit@2.66.0(@sveltejs/vite-plugin-svelte@5.1.1(svelte@5.56.3(@typescript-eslint/types@8.61.1))(vite@6.4.3(@types/node@25.9.4)(jiti@2.7.0)(sass@1.101.0)))(svelte@5.56.3(@typescript-eslint/types@8.61.1))(typescript@5.9.3)(vite@6.4.3(@types/node@25.9.4)(jiti@2.7.0)(sass@1.101.0)))
|
||||||
'@types/js-yaml':
|
'@types/js-yaml':
|
||||||
specifier: ^4.0.9
|
specifier: ^4.0.9
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,5 @@ export default defineConfig({
|
||||||
datasource: {
|
datasource: {
|
||||||
url: process.env['DATABASE_URL'],
|
url: process.env['DATABASE_URL'],
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
2
src/app.d.ts
vendored
2
src/app.d.ts
vendored
|
|
@ -6,7 +6,7 @@ import type { PrismaClient } from '../generated/prisma/client.ts';
|
||||||
declare global {
|
declare global {
|
||||||
namespace App {
|
namespace App {
|
||||||
interface Locals {
|
interface Locals {
|
||||||
prisma: PrismaClient;
|
// prisma: PrismaClient;
|
||||||
}
|
}
|
||||||
// interface Platform {}
|
// interface Platform {}
|
||||||
// interface Session {}
|
// interface Session {}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
import type { Handle } from '@sveltejs/kit';
|
|
||||||
import { PrismaClientFactory } from './prisma/PrismaClientFactory.js';
|
|
||||||
|
|
||||||
export const handle: Handle = async ({ event, resolve }) => {
|
|
||||||
const prismaClient = PrismaClientFactory.fromEnv().createClient();
|
|
||||||
event.locals.prisma = prismaClient;
|
|
||||||
const response = await resolve(event);
|
|
||||||
return response;
|
|
||||||
};
|
|
||||||
12
src/lib/server/prisma.ts
Normal file
12
src/lib/server/prisma.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { PrismaClientFactory } from '../../prisma/PrismaClientFactory.js';
|
||||||
|
import type { PrismaClient } from '../../../generated/prisma/client.js';
|
||||||
|
|
||||||
|
const globalForPrisma = globalThis as unknown as {
|
||||||
|
prisma: PrismaClient | undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const prisma = globalForPrisma.prisma ?? PrismaClientFactory.fromEnv().createClient();
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
globalForPrisma.prisma = prisma;
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,7 @@ import { PRIVATE_PHOTO_UPLOAD_DIR } from '$env/static/private';
|
||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import { error, type ServerLoad } from '@sveltejs/kit';
|
import { error, type ServerLoad } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const GET: ServerLoad = async ({ params, locals }) => {
|
export const GET: ServerLoad = async ({ params }) => {
|
||||||
const { filename } = params;
|
const { filename } = params;
|
||||||
|
|
||||||
const proposedFilePath = path.join(PRIVATE_PHOTO_UPLOAD_DIR, filename);
|
const proposedFilePath = path.join(PRIVATE_PHOTO_UPLOAD_DIR, filename);
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ const config = {
|
||||||
// Consult https://github.com/sveltejs/svelte-preprocess
|
// Consult https://github.com/sveltejs/svelte-preprocess
|
||||||
// for more information about preprocessors
|
// for more information about preprocessors
|
||||||
preprocess: [preprocess()],
|
preprocess: [preprocess()],
|
||||||
|
|
||||||
kit: {
|
kit: {
|
||||||
adapter: adapter({ split: false }),
|
|
||||||
|
adapter: adapter({ split: false, }),
|
||||||
alias: {
|
alias: {
|
||||||
$lib: '/src/lib',
|
$lib: '/src/lib',
|
||||||
$srcPrisma: '/src/prisma',
|
$srcPrisma: '/src/prisma',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue