Config, Schema, Rules
ZeroAPI backends start with three files.
zeroapi.config.ts
Section titled “zeroapi.config.ts”const config = { project: 'myapp'};
export default config;project is the only required field.
Optional overrides stay flat:
const config = { project: 'myapp', name: 'My App', port: 4311, defaultEnvironment: 'production', runtime: { realtime: true, auth: true }};zeroapi.schema.ts
Section titled “zeroapi.schema.ts”const schema = { collections: { tasks: { fields: { id: 'string', workspaceId: 'string', title: 'string', status: 'string', createdBy: 'string', createdAt: 'date' }, defaults: { id: '@randomId', status: 'todo', createdBy: '@uid', createdAt: '@now' }, indexes: [ 'workspaceId', 'status', ['workspaceId', 'status'] ] } }};
export default schema;zeroapi.rules.ts
Section titled “zeroapi.rules.ts”const rules = { collections: { tasks: { ownerField: 'createdBy', create: { allow: ['owner', 'admin', 'member'], where: { workspaceId: '@workspaceId', createdBy: '@uid' } }, read: { allow: ['owner', 'admin', 'member', 'viewer'], where: { workspaceId: '@workspaceId' } } } }};
export default rules;