Skip to content

Commit

Permalink
Schema changes & fix for optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rupamkairi committed Jan 14, 2025
1 parent 98b7954 commit 5e2b6d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 7 additions & 2 deletions apps/server/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ const server = z.object({
NEXT_PUBLIC_LOGTAIL_SOURCE_TOKEN: z.string().optional(),
WHATSAPP_ENDPOINT_URL: z.string(),
WHATSAPP_ENDPOINT_AUTH_TOKEN: z.string(),
PUBLIC_API_CACHING: z.string().optional(),
PUBLIC_API_CACHING: z.union([z.literal("true"), z.literal("false")]).optional()
.transform((val) => {
if (val === undefined) return true; // since it is optional by default caching kept true
return val === "true";
}),
});

/**
Expand Down Expand Up @@ -80,7 +84,8 @@ const processEnv = {
CRON_KEY: process.env.CRON_KEY,
NEXT_PUBLIC_LOGTAIL_SOURCE_TOKEN: process.env.NEXT_PUBLIC_LOGTAIL_SOURCE_TOKEN,
WHATSAPP_ENDPOINT_URL: process.env.WHATSAPP_ENDPOINT_URL,
WHATSAPP_ENDPOINT_AUTH_TOKEN: process.env.WHATSAPP_ENDPOINT_AUTH_TOKEN
WHATSAPP_ENDPOINT_AUTH_TOKEN: process.env.WHATSAPP_ENDPOINT_AUTH_TOKEN,
PUBLIC_API_CACHING: process.env.PUBLIC_API_CACHING
};


Expand Down
8 changes: 2 additions & 6 deletions apps/server/src/pages/api/v1/fires/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { prisma } from "../../../../server/db";
import { logger } from "../../../../server/logger";
import * as process from "node:process";

import { env } from "../../../../env.mjs"


type ResponseData =
Expand All @@ -12,10 +11,7 @@ type ResponseData =
error?: object | unknown;
};

let CACHING = true;
if(process.env.PUBLIC_API_CACHING && process.env.PUBLIC_API_CACHING?.toLowerCase() === "false") {
CACHING = false;
}
const CACHING = env.PUBLIC_API_CACHING ?? true;

export default async function firesBySiteHandler(
req: NextApiRequest,
Expand Down

0 comments on commit 5e2b6d9

Please sign in to comment.