mirror of
https://github.com/hanzo-apps/dataroom.git
synced 2026-10-30 14:47:36 +00:00
31 lines
570 B
TypeScript
31 lines
570 B
TypeScript
import { z } from "zod";
|
|
|
|
export const envSchema = z.object({
|
|
SLACK_APP_INSTALL_URL: z.string(),
|
|
SLACK_CLIENT_ID: z.string(),
|
|
SLACK_CLIENT_SECRET: z.string(),
|
|
SLACK_INTEGRATION_ID: z.string(),
|
|
});
|
|
|
|
type SlackEnv = z.infer<typeof envSchema>;
|
|
|
|
let env: SlackEnv | undefined;
|
|
|
|
export const getSlackEnv = () => {
|
|
if (env) {
|
|
return env;
|
|
}
|
|
|
|
const parsed = envSchema.safeParse(process.env);
|
|
|
|
if (!parsed.success) {
|
|
throw new Error(
|
|
"Slack app environment variables are not configured properly.",
|
|
);
|
|
}
|
|
|
|
env = parsed.data;
|
|
|
|
return env;
|
|
};
|