Skip to content

RemultServerOptions ​

  • RemultServerOptions

entities ​

Entities to use for the api

controllers ​

Controller to use for the api

getUser ​

Will be called to get the current user based on the current request

initRequest ​

Will be called for each request and can be used for configuration

initApi ​

Will be called once the server is loaded and the data provider is ready

dataProvider ​

Data Provider to use for the api.

see: ​

Connecting to a Database.

ensureSchema ​

Will create tables and columns in supporting databases.

default: ​

ts
true

when set to true, it'll create entities that do not exist, and add columns that are missing.

rootPath ​

The path to use for the api, if you want to use a different path adjust this field

default: ​

/api

defaultGetLimit ​

The default limit to use for find requests that did not specify a limit

logApiEndPoints ​

When set to true (default) it'll console log each api endpoint that is created

subscriptionServer ​

A subscription server to use for live query and message channels

liveQueryStorage ​

A storage to use to store live queries, relevant mostly for serverless scenarios or larger scales

contextSerializer ​

Used to store the context relevant info for re running a live query

admin ​

When set to true, will display an admin ui in the /api/admin url. Can also be set to an arrow function for fine grained control

example: ​

ts
admin: true

example: ​

ts
admin: () => remult.isAllowed('admin')

see: ​

allowed

queueStorage ​

Storage to use for backend methods that use queue

error ​

This method is called whenever there is an error in the API lifecycle.

example: ​

ts
export const api = remultApi({
  error: async (e) => {
    if (e.httpStatusCode == 400) {
      e.sendError(500, { message: "An error occurred" })
    }
  }
})

modules ​

Modules are here to group code by feature. Module Guide

example: ​

ts
import { Module } from 'remult/server'

// create an analytics module
const analytics = () => new Module({
  key: 'analytics',
  priority: 11, // Default: 0, Prioritized by ascending order.
  entities: [AnalyticsEvent],
  controllers: [AnalyticsController],
  initApi: () => console.log('analytics module initialized'),
  initRequest: () => {},
  modules: [] // You can nest modules
})

// use the module in the remultApi
remultApi({
  modules: [
    analytics(),
  ]
})

MIT Licensed | Made by the Remult team with ❤️