QuickStart
Welcome to the Restura Quickstart! This guide will walk you through the process of setting up a new Restura project.
Before you begin
Section titled “Before you begin”Make sure you have:
- Node.js 18+ installed on your machine
- An ExpressJS application (Express 5+)
- Credentials for a PostgreSQL database
- A terminal to execute commands
Installation
Section titled “Installation”Start by installing the Restura Engine. Run the following command in your terminal:
npm install @restura/corepnpm add @restura/coreyarn add @restura/corebun add @restura/coreInitialize Restura in Your Express App
Section titled “Initialize Restura in Your Express App”In your ExpressJS entry file, add the following code to initialize the Restura Engine:
import { PsqlPool, restura, type OnValidAuthenticationCallback, type RsRequest, type RsResponse } from '@restura/core';import express from 'express';
const app = express();
// Create a PostgreSQL connection poolconst pool = new PsqlPool({host: "<host>", // Replace with your database hostport: <port>, // Replace with your database portuser: "<user>", // Replace with your database userpassword: "<password>", // Replace with your database passworddatabase: "<database>", // Replace with your database name});
// Define an authentication handlerconst authHandler = async (req: RsRequest<unknown>, res: RsResponse<unknown>, onValid: OnValidAuthenticationCallback) => {onValid({ role: 'user', scopes: [] });};
// Initialize Resturaawait restura.init(app, authHandler, pool);
app.listen(3001, () => { // This is the default port for the Restura Engineconsole.log('Server is running on port 3001');});const { PsqlPool, restura } = require('@restura/core');const express = require('express');
const app = express();
// Create a PostgreSQL connection poolconst pool = new PsqlPool({host: "<host>", // Replace with your database hostport: <port>, // Replace with your database portuser: "<user>", // Replace with your database userpassword: "<password>", // Replace with your database passworddatabase: "<database>", // Replace with your database name});
// Define an authentication handlerconst authHandler = async (req, res, onValid) => {onValid({ role: 'user', scopes: [] });};
// Initialize Restura(async () => {await restura.init(app, authHandler, pool);
app.listen(3001, () => { // This is the default port for the Restura Engineconsole.log('Server is running on port 3001');});})();The Restura Engine is initialized by calling restura.init with the following parameters:
app- An instance of the Express applicationauthHandler- An authentication handler functionpool- An instance of thePsqlPoolclass
Create a Restura Schema file
Section titled “Create a Restura Schema file”The schema file defines your database tables, API endpoints, and access control. Restura reads this file on startup and generates everything needed to run your API.
Create a restura.schema.json file in your project root.
Add this minimal schema to get started:
{ "customTypes": [], "database": [], "endpoints": [ { "baseUrl": "/api/v1", "description": "V1 Endpoints", "name": "V1", "routes": [] } ], "globalParams": ["userId"], "roles": ["user"], "scopes": ["read:user", "write:user"]}Make a Restura Configuration file
Section titled “Make a Restura Configuration file”Restura loads a configuration file from the root of your project on startup called restura.config.mjs.
Create a restura.config.mjs file in your project root.
Add the following content:
export default { logger: { level: "info" // Default log level is info }, restura: { authToken: "12345" // This is the auth token used by the visual editor to update the schema }}Run the Restura Engine
Section titled “Run the Restura Engine”Now that you have installed and added the required files, you can run the Restura Engine by starting your Express application.
npm start # or pnpm start, yarn start, bun start, etc.When the Restura Engine starts, it will:
- Load and validate your schema file
- Generate TypeScript type definitions in
src/@types/:api.d.ts- API endpoint typesmodel.d.ts- Database table typesrestura.d.ts- General types used by Restura
- Register all endpoints defined in your schema
- Start listening for requests
You should see output like:
INFO [2026-01-12 04:25:34.373]: Restura loaded (0) endpointINFO [2026-01-12 04:25:34.379]: Restura Engine InitializedINFO [2026-01-12 04:25:34.495]: Successfully connected to database triggersINFO [2026-01-12 04:25:34.498]: Connected to PostgreSQL databaseWhat’s Next?
Section titled “What’s Next?”Now that Restura is installed and running, you can:
- Run the Visual Editor - Use the UI to manage your schema visually
- Create your first database table - Define tables using the Visual Editor
- Build a standard endpoint - Create a GET endpoint that queries your data
Or dive deeper: