asu_tools_service/handlers/reports/syncParsed.handler.js
2026-03-04 15:37:16 +03:00

32 lines
940 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { BadRequestError } from "#root/http-server/index.js";
import yup from "yup";
var reportItemSchema = yup.object({
date: yup.date().required(),
equipment: yup.string().nullable().required(),
reason_call: yup.string().required(),
job_description: yup.string().required(),
root_cause: yup.string().required(),
applicant: yup.number().required(),
executor_ids: yup.array(yup.number()).required()
});
/**
* URL: /api/reports_sync
* Method: POST
* Description: Синхронизирует принятые отчеты с отчетами в БД
*
* @type {import("#root/http-server/types/http-server.js").HttpRouteHandler}
*/
export default async ({ res, data }) => {
const inputSchema = yup.object({ reports: yup.array(reportItemSchema).required() }).required();
await inputSchema.validate(data).catch((err) => {
throw new BadRequestError(err.message);
});
// TODO ...
res.sendJson({ data });
};