mirror of
https://github.com/sergeyyarkov/asu_tools_service.git
synced 2026-10-11 10:29:22 +03:00
32 lines
940 B
JavaScript
32 lines
940 B
JavaScript
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 });
|
||
};
|