MasterController
Components
Self-contained mini-apps you can mount into any project.
A component is a mountable module with its own routes, controllers, services, models, and sockets — great for an admin panel, a billing module, or a reusable feature shared across apps.
Component layout#
text
components/billing/
config/
routes.js # the component's routes
initializers/config.js # optional init (pipeline.use, services)
app/
controllers/billingController.js
models/
sockets/Defining a component#
components/billing/config/routes.js
import master from 'mastercontroller';
const router = master.router.start();
router.route('/billing', 'billing#index', 'get');components/billing/app/controllers/billingController.js
export default class BillingController {
constructor(requestObject) { this.requestObject = requestObject; }
async index() { this.returnJson({ ok: true, component: 'billing' }); }
}Registering a component#
Mount it in server.js after setupServer():
javascript
await master.component('components', 'billing'); Tip
Scaffold the whole structure with
master generate component billing. The framework discovers the component’s routes, controllers, services, models, and sockets automatically when you register it.