Merged in feature/SW-2538-redis-api-sentry (pull request #1973)
Feature/SW-2538 redis api sentry * Add fingerprint to be able to differentiate JSON.parse errors * update deploy script * use status over deprecated error function in elysia * use t3-env createFinalSchema for extra validation Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -3,6 +3,7 @@ import { z } from "zod";
|
||||
|
||||
const redisConnectionRegex =
|
||||
/^((?<username>.*?):(?<password>.*?)@)?(?<host>.*?):(?<port>\d+)$/;
|
||||
|
||||
export const env = createEnv({
|
||||
server: {
|
||||
IS_PROD: z
|
||||
@@ -34,6 +35,33 @@ export const env = createEnv({
|
||||
process.env.NODE_ENV === "development"
|
||||
? z.string().optional()
|
||||
: z.string().min(10),
|
||||
SENTRY_DSN: z.string().min(1).optional(),
|
||||
SENTRY_ENVIRONMENT: z
|
||||
.enum(["development", "test", "stage", "pre-prod", "production"])
|
||||
.default("development"),
|
||||
SENTRY_ENABLED: z
|
||||
.string()
|
||||
.refine((s) => s === "true" || s === "false")
|
||||
.transform((s) => s === "true"),
|
||||
SENTRY_TRACE_SAMPLE_RATE: z.coerce.number().default(0.001),
|
||||
},
|
||||
createFinalSchema: (shape) => {
|
||||
return z.object(shape).transform((env, ctx) => {
|
||||
if (!env.SENTRY_ENABLED || !env.SENTRY_DSN) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message:
|
||||
"SENTRY_DSN is required when SENTRY_ENABLED is true",
|
||||
});
|
||||
|
||||
return z.NEVER;
|
||||
}
|
||||
|
||||
return {
|
||||
...env,
|
||||
SENTRY_ENABLED: env.SENTRY_ENABLED && !!env.SENTRY_DSN,
|
||||
};
|
||||
});
|
||||
},
|
||||
runtimeEnv: {
|
||||
...process.env,
|
||||
|
||||
Reference in New Issue
Block a user