mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
use global client everywhere
This commit is contained in:
16
db/client.ts
Normal file
16
db/client.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// allow global `var` declarations
|
||||||
|
// eslint-disable-next-line no-var
|
||||||
|
var prisma: PrismaClient | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export const prisma =
|
||||||
|
global.prisma ||
|
||||||
|
new PrismaClient({
|
||||||
|
log: ['query'],
|
||||||
|
})
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== 'production') global.prisma = prisma
|
||||||
14
db/index.ts
14
db/index.ts
@@ -4,19 +4,7 @@ import { getBookedDays as calendarGetBookedDays } from '../lib/googlecalendar'
|
|||||||
import { uniqueFilter } from '../helpers/array'
|
import { uniqueFilter } from '../helpers/array'
|
||||||
import { dateFormatBackend, getDays, nowInTz } from '../helpers/date'
|
import { dateFormatBackend, getDays, nowInTz } from '../helpers/date'
|
||||||
|
|
||||||
declare global {
|
import { prisma } from './client'
|
||||||
// allow global `var` declarations
|
|
||||||
// eslint-disable-next-line no-var
|
|
||||||
var prisma: PrismaClient | undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
export const prisma =
|
|
||||||
global.prisma ||
|
|
||||||
new PrismaClient({
|
|
||||||
log: ['query'],
|
|
||||||
})
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') global.prisma = prisma
|
|
||||||
|
|
||||||
export async function getBookedDays(
|
export async function getBookedDays(
|
||||||
uuidsToIngore?: string[]
|
uuidsToIngore?: string[]
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ import EmailProvider from 'next-auth/providers/email'
|
|||||||
import GitHubProvider from 'next-auth/providers/github'
|
import GitHubProvider from 'next-auth/providers/github'
|
||||||
|
|
||||||
import { PrismaAdapter } from "@next-auth/prisma-adapter"
|
import { PrismaAdapter } from "@next-auth/prisma-adapter"
|
||||||
import { PrismaClient } from "@prisma/client"
|
|
||||||
|
|
||||||
const prisma = new PrismaClient()
|
import { prisma } from '../../../db/client';
|
||||||
|
|
||||||
const ADMIN_EMAIL = process.env.ADMIN_EMAIL
|
const ADMIN_EMAIL = process.env.ADMIN_EMAIL
|
||||||
const GITHUB_USERS_GRANTED = ['111471']
|
const GITHUB_USERS_GRANTED = ['111471']
|
||||||
|
|||||||
Reference in New Issue
Block a user