@premieroctet/next-admin
Version:
Next-Admin provides a customizable and turnkey admin dashboard for applications built with Next.js and powered by the Prisma ORM. It aims to simplify the development process by providing a turnkey admin system that can be easily integrated into your proje
23 lines (22 loc) • 778 B
JavaScript
let schema = null;
let resources = null;
const initGlobals = async ()=>{
try {
if (schema && resources) return;
const schemaDef = await import("@premieroctet/next-admin/schema");
schema = schemaDef.default;
resources = Object.keys(schema.definitions).filter((modelName)=>!schema.definitions[modelName].enum);
} catch (e) {
console.error(e);
throw new Error("Schema not found, make sure you added the generator to your schema.prisma file");
}
};
const getSchema = ()=>{
if (!schema) throw new Error("Schema not initialized");
return schema;
};
const getResources = ()=>{
if (!resources) throw new Error("Resources not initialized");
return resources;
};
export { getResources, getSchema, initGlobals };