Spaces:
Runtime error
Runtime error
File size: 1,283 Bytes
5e518ea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import { RouterBroker } from '@api/abstract/abstract.router';
import { HandleLabelDto, LabelDto } from '@api/dto/label.dto';
import { labelController } from '@api/server.module';
import { handleLabelSchema } from '@validate/validate.schema';
import { RequestHandler, Router } from 'express';
import { HttpStatus } from './index.router';
export class LabelRouter extends RouterBroker {
constructor(...guards: RequestHandler[]) {
super();
this.router
.get(this.routerPath('findLabels'), ...guards, async (req, res) => {
const response = await this.dataValidate<LabelDto>({
request: req,
schema: null,
ClassRef: LabelDto,
execute: (instance) => labelController.fetchLabels(instance),
});
return res.status(HttpStatus.OK).json(response);
})
.post(this.routerPath('handleLabel'), ...guards, async (req, res) => {
const response = await this.dataValidate<HandleLabelDto>({
request: req,
schema: handleLabelSchema,
ClassRef: HandleLabelDto,
execute: (instance, data) => labelController.handleLabel(instance, data),
});
return res.status(HttpStatus.OK).json(response);
});
}
public readonly router: Router = Router();
}
|