Moonbase Documentation

Backend Runtime Overview

How the API loads and runs plugins.

The backend plugin loader scans for JavaScript plugins at startup and loads them in order.

Plugin locations

The loader checks these directories (first match wins):

plugins
api/plugins
the packaged plugins directory next to the loader (internal fallback)

Recommended location

In most cases you should place plugins in api/plugins.

Load order

Plugins load in alphabetical order by filename.

Supported files

File types

`.js`, `.cjs`, or `.mjs`

Folder entry

Folder with `index.js`, `index.cjs`, or `index.mjs`

Ignored entries

Names starting with `_` or `.` are skipped

Plugin shape

module.exports = {
  name: 'my-plugin',
  enabled: true,
  version: '0.1.0',
  register(ctx) {
    ctx.logger.info('plugin loaded');
  }
};
module.exports = function register(ctx) {
  // ...
};

Naming and lifecycle

If you omit name, the filename becomes the plugin name. init(ctx) is treated the same as register(ctx).

Enabled flag and logs

The loader logs successful and failed plugins at startup. If enabled is false, the plugin is skipped and the API logs that it is disabled.

On this page