Allow to create a new Forest Admin agent from scratch. Builds the application by composing and configuring all the collection decorators.

Minimal code to add a datasource

Example

new AgentBuilder(options)
.addDataSource(new SomeDataSource())
.start();

Type Parameters

Hierarchy

  • default
    • Agent

Constructors

  • Create a new Agent Builder. If any options are missing, the default will be applied:

     forestServerUrl: 'https://api.forestadmin.com',
    logger: (level, data) => console.error(level, data),
    prefix: 'api/v1',
    schemaPath: '.forestadmin-schema.json',
    permissionsCacheDurationInSeconds: 15 * 60,

    Example

    new AgentBuilder(options)
    .addDataSource(new DataSource())
    .start();

    Type Parameters

    Parameters

    Returns Agent<S>

Properties

customizationService: default
customizer: DataSourceCustomizer<S>
nocodeCustomizer: DataSourceCustomizer<S>
options: Readonly<Required<AgentOptions>>
standaloneServerPort: number

Methods

  • Parameters

    • router: Router<DefaultState, DefaultContext>

    Returns Promise<void>

  • Mount the agent on a fastify app

    Parameters

    • fastify: any

      instance of the fastify app, or of a fastify context

    Returns Agent<S>

  • Expose the agent on a given port and host

    Parameters

    • Optional port: number

      port that should be used, defaults to 3351 or to the PORT environment variable. O will be set a random available port and the port will be available in the standaloneServerPort property.

    • Optional host: string

      host that should be used, default to the unspecified IPv6 address (::) when IPv6 is available, or the unspecified IPv4 address (0.0.0.0) otherwise.

    Returns Agent<S>

  • Parameters

    • router: Router<DefaultState, DefaultContext>

    Returns Promise<void>

  • Remove collections from the exported schema (they will still be usable within the agent).

    Example

    .removeField('aCollectionToRemove', 'anotherCollectionToRemove');
    

    Parameters

    • Rest ...names: Extract<keyof S, string>[]

      the collections to remove

    Returns Agent<S>

  • Update the typings files generated from your datasources

    See

    Documentation Link

    Parameters

    • typingsPath: string

      the path at which to write the new file

    • typingsMaxDepth: number

      the max depth of relation typings

    Returns Promise<void>

  • Load a plugin across all collections

    See

    Documentation Link

    Example

    import advancedExportPlugin from '@forestadmin/plugin-advanced-export';

    agent.use(advancedExportPlugin, { format: 'xlsx' });

    Type Parameters

    • Options

    Parameters

    • plugin: Plugin<Options>

      instance of the plugin

    • Optional options: Options

      options which need to be passed to the plugin

    Returns Agent<S>