-
Notifications
You must be signed in to change notification settings - Fork 6k
Expand file tree
/
Copy pathcall.router.ts
More file actions
25 lines (21 loc) · 868 Bytes
/
call.router.ts
File metadata and controls
25 lines (21 loc) · 868 Bytes
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
import { RouterBroker } from '@api/abstract/abstract.router';
import { OfferCallDto } from '@api/dto/call.dto';
import { callController } from '@api/server.module';
import { offerCallSchema } from '@validate/validate.schema';
import { RequestHandler, Router } from 'express';
import { HttpStatus } from './index.router';
export class CallRouter extends RouterBroker {
constructor(...guards: RequestHandler[]) {
super();
this.router.post(this.routerPath('offer'), ...guards, async (req, res) => {
const response = await this.dataValidate<OfferCallDto>({
request: req,
schema: offerCallSchema,
ClassRef: OfferCallDto,
execute: (instance, data) => callController.offerCall(instance, data),
});
return res.status(HttpStatus.CREATED).json(response);
});
}
public readonly router: Router = Router();
}