Files
myeasycms-v2/packages/supabase/src/get-service-role-key.ts
giancarlo 24e5c0debd Refine warning messages and test feedback
This commit refines the warning text in the 'deleteAccountDescription' in locales and associated Supabase service role warning. Additionally, the E2E test for account deletion has been updated to include a response check for a redirection status, improving the reliability of the test outcome.
2024-04-13 13:49:40 +08:00

19 lines
550 B
TypeScript

import { z } from 'zod';
/**
* @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() {
const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY;
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.`,
);
}
return z.string().min(1).parse(serviceRoleKey);
}