Multiuser support (#60)

This commit is contained in:
Doh
2025-02-18 23:43:23 -05:00
committed by GitHub
parent 363b31e934
commit 8ac2ec053d
48 changed files with 2678 additions and 271 deletions

31
lib/env.server.ts Normal file
View File

@@ -0,0 +1,31 @@
import { z } from "zod"
const zodEnv = z.object({
AUTH_SECRET: z.string(),
NEXT_PUBLIC_DEMO: z.string().optional(),
})
declare global {
interface ProcessEnv extends z.TypeOf<typeof zodEnv> {
AUTH_SECRET: string;
NEXT_PUBLIC_DEMO?: string;
}
}
try {
zodEnv.parse(process.env)
} catch (err) {
if (err instanceof z.ZodError) {
const { fieldErrors } = err.flatten()
const errorMessage = Object.entries(fieldErrors)
.map(([field, errors]) =>
errors ? `${field}: ${errors.join(", ")}` : field,
)
.join("\n ")
console.error(
`Missing environment variables:\n ${errorMessage}`,
)
process.exit(1)
}
}