Skip to Content
DocsConceptsConfig

Config

An app has one config, usually in quickben.config.ts. defineConfig returns it typed by collection slug.

quickben.config.ts
import { defineCollection, defineConfig, devAuth, fields as f } from "@quickben/core"; import { memoryAdapter } from "@quickben/db-memory"; const tags = defineCollection({ slug: "tags", fields: { name: f.text({ required: true, unique: true }) }, }); export default defineConfig({ db: memoryAdapter(), collections: [tags], plugins: [], auth: devAuth(), admin: { title: "Acme back office" }, modules: [{ key: "content", label: "Content", collections: ["tags"] }], });

Options

OptionTypeRequiredPurpose
dbDatabaseAdapteryesStorage. See Database adapters.
collectionsAnyCollection[]yesYour collections, from defineCollection.
pluginsPlugin[]noApplied in order. See Plugins and modules.
authAuthAdapternoResolves the user of a request. See Auth adapters.
admin{ title?: string }noAdmin UI options. title defaults to Quickben.
modulesModule[]noFeature areas that group collections.

What defineConfig checks

It throws ConfigError when:

ProblemExample message
Two collections share a slugDuplicate collection slug "posts"
A relation points to a missing collectionField "posts.author" relates to unknown collection "users"
Two modules share a keyDuplicate module key "sales"
A module lists a missing collectionModule "sales" lists unknown collection "deals"
A plugin is applied twicePlugin "audit" is applied twice

Types from the config

import type { InferDoc, InferRegistry } from "@quickben/core"; type Registry = InferRegistry<typeof config>; type Post = InferDoc<Registry["posts"]>;

InferRegistry includes collections added by plugins.

Last updated on