Refactor replace some HTTP related magic values by enums.

This commit is contained in:
baldo 2022-09-20 19:09:49 +02:00
parent c988227bc7
commit 15d3f45bae
9 changed files with 135 additions and 24 deletions
server/resources

View file

@ -14,6 +14,7 @@ import {
TaskState,
UnixTimestampSeconds,
} from "../types";
import { HttpHeader } from "../shared/utils/http";
const isValidId = forConstraint(CONSTRAINTS.id, false);
@ -109,7 +110,7 @@ async function doGetAll(
export function getAll(req: Request, res: Response): void {
doGetAll(req)
.then(({ total, pageTasks }) => {
res.set("X-Total-Count", total.toString(10));
res.set(HttpHeader.X_TOTAL_COUNT, total.toString(10));
Resources.success(res, pageTasks.map(toTaskResponse));
})
.catch((err) => Resources.error(res, err));