23 lines
730 B
TypeScript
23 lines
730 B
TypeScript
|
import { Request, Response } from "express";
|
||
|
import ProtocolService from "../../service/protocolService";
|
||
|
import ProtocolFactory from "../../factory/admin/protocol";
|
||
|
|
||
|
/**
|
||
|
* @description get all protocols
|
||
|
* @param req {Request} Express req object
|
||
|
* @param res {Response} Express res object
|
||
|
* @returns {Promise<*>}
|
||
|
*/
|
||
|
export async function getAllProtocols(req: Request, res: Response): Promise<any> {
|
||
|
let offset = parseInt((req.query.offset as string) ?? "0");
|
||
|
let count = parseInt((req.query.count as string) ?? "25");
|
||
|
let [protocols, total] = await ProtocolService.getAll(offset, count);
|
||
|
|
||
|
res.json({
|
||
|
protocols: ProtocolFactory.mapToBase(protocols),
|
||
|
total: total,
|
||
|
offset: offset,
|
||
|
count: count,
|
||
|
});
|
||
|
}
|