diff --git a/frontends/nextjs/.env.example b/frontends/nextjs/.env.example new file mode 100644 index 000000000..530d91173 --- /dev/null +++ b/frontends/nextjs/.env.example @@ -0,0 +1,4 @@ +# Database connection URL +# For SQLite (default): file:./dev.db +# For PostgreSQL: postgresql://user:password@localhost:5432/metabuilder +DATABASE_URL="file:./dev.db" diff --git a/frontends/nextjs/package.json b/frontends/nextjs/package.json index 8f88b04a9..cd30d7680 100644 --- a/frontends/nextjs/package.json +++ b/frontends/nextjs/package.json @@ -3,9 +3,6 @@ "private": true, "version": "0.0.0", "type": "module", - "prisma": { - "schema": "../../prisma/schema.prisma" - }, "scripts": { "dev": "next dev", "build": "next build --webpack", diff --git a/frontends/nextjs/src/lib/db/index.ts b/frontends/nextjs/src/lib/db/index.ts index 325d5edbf..a9ffe30b9 100644 --- a/frontends/nextjs/src/lib/db/index.ts +++ b/frontends/nextjs/src/lib/db/index.ts @@ -20,6 +20,7 @@ export * from './pages' export * from './schemas' export * from './comments' export * from './app-config' +export * from './system-config' export * from './components' export * from './css-classes' export * from './dropdown-configs' @@ -42,6 +43,7 @@ import * as pages from './pages' import * as schemas from './schemas' import * as comments from './comments' import * as appConfig from './app-config' +import * as systemConfig from './system-config' import * as components from './components' import * as cssClasses from './css-classes' import * as dropdownConfigs from './dropdown-configs' @@ -121,6 +123,9 @@ export class Database { static getAppConfig = appConfig.getAppConfig static setAppConfig = appConfig.setAppConfig + // System Config + static getSystemConfigValue = systemConfig.getSystemConfigValue + // Components static getComponentHierarchy = components.getComponentHierarchy static setComponentHierarchy = components.setComponentHierarchy diff --git a/frontends/nextjs/src/lib/db/system-config/get-system-config-value.ts b/frontends/nextjs/src/lib/db/system-config/get-system-config-value.ts new file mode 100644 index 000000000..342256b25 --- /dev/null +++ b/frontends/nextjs/src/lib/db/system-config/get-system-config-value.ts @@ -0,0 +1,13 @@ +import { getAdapter } from '../dbal-client' + +/** + * Fetch a SystemConfig value by key. + */ +export async function getSystemConfigValue(key: string): Promise { + const adapter = getAdapter() + const config = await adapter.findFirst('SystemConfig', { + where: { key }, + }) as { value?: string } | null + + return typeof config?.value === 'string' ? config.value : null +} diff --git a/frontends/nextjs/src/lib/db/system-config/index.ts b/frontends/nextjs/src/lib/db/system-config/index.ts new file mode 100644 index 000000000..a8ae02f14 --- /dev/null +++ b/frontends/nextjs/src/lib/db/system-config/index.ts @@ -0,0 +1 @@ +export { getSystemConfigValue } from './get-system-config-value'