@uisap/core
Version:
A modular Fastify-based framework inspired by Laravel
25 lines (22 loc) • 819 B
JavaScript
// example/controllers/machinesController.js
import { BaseController } from '@uisap/core';
import { SapDataUpdated } from '../events/sapDataUpdated.js';
export class MachinesController extends BaseController {
constructor(fastify) {
super(fastify);
this.dataModel = this.resolve('DataModel');
this.model = this.resolve('InstructionModel');
this.events = this.resolve('events');
}
async getMachines(request, reply) {
const results = await this.model.getMachines();
return reply.send(results);
}
async getSapData(request, reply) {
const results = await this.dataModel.getSapData();
const event = new SapDataUpdated(results);
await this.events.fire(event); // Olayı ateşle
await event.broadcastWith(this.fastify); // Broadcast et
return reply.send(results);
}
}