This commit updates diverse packages such as "@makerkit/data-loader-supabase-core" and "@makerkit/data-loader-supabase-nextjs" to the new versions in the package.json files. Also, several refactorings were done in logging within services and loaders by progressing 'server-only' imports and improving context handling. Additionally, type annotations have been added to several exported functions for better code readability and maintainability.
25 lines
578 B
TypeScript
25 lines
578 B
TypeScript
import { notFound } from 'next/navigation';
|
|
|
|
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
|
|
|
|
import { isSuperAdmin } from './is-super-admin';
|
|
|
|
/**
|
|
* @name enhanceAdminAction
|
|
* @description Wrap a server action to ensure the user is a super admin.
|
|
* @param fn
|
|
*/
|
|
export function enhanceAdminAction<Args, Response>(
|
|
fn: (params: Args) => Response,
|
|
) {
|
|
return async (params: Args) => {
|
|
const isAdmin = await isSuperAdmin(getSupabaseServerActionClient());
|
|
|
|
if (!isAdmin) {
|
|
notFound();
|
|
}
|
|
|
|
return fn(params);
|
|
};
|
|
}
|