Files
medreport_mrb2b/packages/supabase/src/get-service-role-key.ts
Helena 9122acc89f MED-151: add profile view and working smoking dashboard card (#71)
* MED-151: add profile view and working smoking dashboard card

* update zod

* move some components to shared

* move some components to shared

* remove console.logs

* remove unused password form components

* only check null for variant

* use pathsconfig
2025-09-04 12:17:54 +03:00

34 lines
856 B
TypeScript

import 'server-only';
import { z } from 'zod';
const message =
'Invalid Supabase Service Role Key. Please add the environment variable SUPABASE_SERVICE_ROLE_KEY.';
/**
* @name getServiceRoleKey
* @description Get the Supabase Service Role Key.
* ONLY USE IN SERVER-SIDE CODE. DO NOT EXPOSE THIS TO CLIENT-SIDE CODE.
*/
export function getServiceRoleKey() {
return z
.string({
error: message,
})
.min(1, {
message: message,
})
.parse(process.env.SUPABASE_SERVICE_ROLE_KEY);
}
/**
* Displays a warning message if the Supabase Service Role is being used.
*/
export function warnServiceRoleKeyUsage() {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`[Dev Only] This is a simple warning to let you know you are using the Supabase Service Role. Make sure it's the right call.`,
);
}
}