Allows for the creation of user accounts. A few notes on the specifics: - Experiments are the main access control objects. If you can view an experiment, you can view all its prompts/scenarios/evals. If you can edit it, you can edit or delete all of those as well. - Experiments are owned by Organizations in the database. Organizations can have multiple members and members can have roles of ADMIN, MEMBER or VIEWER. - Organizations can either be "personal" or general. Each user has a "personal" organization created as soon as they try to create an experiment. There's currently no UI support for creating general orgs or adding users to them; they're just in the database to future-proof all the ACL logic. - You can require that a user is signed-in to see a route using the `protectedProcedure` helper. When you use `protectedProcedure`, you also have to call `ctx.markAccessControlRun()` (or delegate to a function that does it for you; see accessControl.ts). This is to remind us to actually check for access control when we define a new endpoint.
52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
import { createEnv } from "@t3-oss/env-nextjs";
|
|
import { z } from "zod";
|
|
|
|
export const env = createEnv({
|
|
/**
|
|
* Specify your server-side environment variables schema here. This way you can ensure the app
|
|
* isn't built with invalid env vars.
|
|
*/
|
|
server: {
|
|
DATABASE_URL: z.string().url(),
|
|
NODE_ENV: z.enum(["development", "test", "production"]).default("development"),
|
|
OPENAI_API_KEY: z.string().min(1),
|
|
RESTRICT_PRISMA_LOGS: z
|
|
.string()
|
|
.optional()
|
|
.default("false")
|
|
.transform((val) => val.toLowerCase() === "true"),
|
|
GITHUB_CLIENT_ID: z.string().min(1),
|
|
GITHUB_CLIENT_SECRET: z.string().min(1),
|
|
},
|
|
|
|
/**
|
|
* Specify your client-side environment variables schema here. This way you can ensure the app
|
|
* isn't built with invalid env vars. To expose them to the client, prefix them with
|
|
* `NEXT_PUBLIC_`.
|
|
*/
|
|
client: {
|
|
NEXT_PUBLIC_POSTHOG_KEY: z.string().optional(),
|
|
NEXT_PUBLIC_SOCKET_URL: z.string().url().default("http://localhost:3318"),
|
|
},
|
|
|
|
/**
|
|
* You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g.
|
|
* middlewares) or client-side so we need to destruct manually.
|
|
*/
|
|
runtimeEnv: {
|
|
DATABASE_URL: process.env.DATABASE_URL,
|
|
NODE_ENV: process.env.NODE_ENV,
|
|
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
|
|
RESTRICT_PRISMA_LOGS: process.env.RESTRICT_PRISMA_LOGS,
|
|
NEXT_PUBLIC_POSTHOG_KEY: process.env.NEXT_PUBLIC_POSTHOG_KEY,
|
|
NEXT_PUBLIC_SOCKET_URL: process.env.NEXT_PUBLIC_SOCKET_URL,
|
|
GITHUB_CLIENT_ID: process.env.GITHUB_CLIENT_ID,
|
|
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET,
|
|
},
|
|
/**
|
|
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
|
|
* This is especially useful for Docker builds.
|
|
*/
|
|
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
|
|
});
|