Introduction

UltimaBase is a TypeScript backend built from a small kernel and its plugins.

UltimaBase is a backend written in TypeScript. You declare models, their fields and who may read and write them; it serves them over GraphQL or REST, on PostgreSQL or in memory. A small kernel holds the models, the queries and the access rules, and every other feature is a plugin: HTTP, GraphQL, REST, sign-in, files, realtime, the databases.

A model, and the rule that decides what a client reads:

import { defineModel } from 'ultimabase'

export const Post = defineModel({
	name: 'Post',
	fields: (f) => ({
		title: f.string(),
		published: f.boolean({ default: false }),
	}),
}).with({
	// Clients read the published posts; the other rules, left out, are
	// closed: only server code writes.
	access: { read: ({ where }) => where({ published: true }) },
})

The full example, with its tests: examples/introduction.

The GraphQL API serves the posts, the rule applied: a client gets the published post, not the draft.

// `{ as: master }` is your server code, past every rule: it writes a
// published post and a draft.
await Post.createMany(
	{ data: [{ title: 'Hello', published: true }, { title: 'Draft' }] },
	{ as: master },
)
// `request` sends a GraphQL query as an anonymous client would.
expect(await request('{ posts { edges { node { title } } } }')).toEqual({
	data: { posts: { edges: [{ node: { title: 'Hello' } }] } },
})

Start an application, then follow the Quickstart:

npm create ultimabase@latest my-app

The documentation

On this page