MrLowLevel
MrLowLevel
TTCTheo's Typesafe Cult
Created by MrLowLevel on 6/28/2023 in #questions
`env.mjs` as opposed to `env.cjs` or `env.js`
yah indeed testing that now
11 replies
TTCTheo's Typesafe Cult
Created by MrLowLevel on 6/28/2023 in #questions
`env.mjs` as opposed to `env.cjs` or `env.js`
ok yeah then next gets mad
import { z } from 'zod'
^^^^^^

SyntaxError: Cannot use import statement outside a module
import { z } from 'zod'
^^^^^^

SyntaxError: Cannot use import statement outside a module
11 replies
TTCTheo's Typesafe Cult
Created by MrLowLevel on 6/28/2023 in #questions
`env.mjs` as opposed to `env.cjs` or `env.js`
let me see if anything breaks if I just convert env.mjs to env.js in all the places
11 replies
TTCTheo's Typesafe Cult
Created by MrLowLevel on 6/28/2023 in #questions
`env.mjs` as opposed to `env.cjs` or `env.js`
yeah our t3 init version is 7.5.1
11 replies
TTCTheo's Typesafe Cult
Created by MrLowLevel on 6/28/2023 in #questions
`env.mjs` as opposed to `env.cjs` or `env.js`
I think the reason ts doesn't work is because of this line in next.config.mjs
!process.env.SKIP_ENV_VALIDATION && (await import('./src/env.mjs'))
!process.env.SKIP_ENV_VALIDATION && (await import('./src/env.mjs'))
11 replies
TTCTheo's Typesafe Cult
Created by ahkhanjani on 6/24/2023 in #questions
Prisma client extensions in T3 app
We solved this like so:
export function getPrisma() {
return new BasePrismaClient({
// log: ['error'],
log:
env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
})
.$extends(brandExtension)
// ...
}

export type PrismaClient = ReturnType<typeof getPrisma>
export type TransactionClient = Parameters<
Parameters<PrismaClient['$transaction']>[0]
>[0]
export function getPrisma() {
return new BasePrismaClient({
// log: ['error'],
log:
env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
})
.$extends(brandExtension)
// ...
}

export type PrismaClient = ReturnType<typeof getPrisma>
export type TransactionClient = Parameters<
Parameters<PrismaClient['$transaction']>[0]
>[0]
And then use this PrismaClient type definition in the globals instead of the prisma-exported one
import { PrismaClient, getPrisma } from './prisma'

const globals = globalThis as unknown as {
__prisma: PrismaClient
}

export const prisma = globals.__prisma || getPrisma()
import { PrismaClient, getPrisma } from './prisma'

const globals = globalThis as unknown as {
__prisma: PrismaClient
}

export const prisma = globals.__prisma || getPrisma()
20 replies