Skip to content

Config, Schema, Rules

ZeroAPI backends start with three files.

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
}
};
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;
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;