This commit is contained in:
Sergey Yarkov 2026-08-26 12:56:59 +03:00
parent 53a8cab4fb
commit 8d0536e779
5 changed files with 17 additions and 6 deletions

View File

@ -3,6 +3,8 @@ import { clients } from "#root/index.js";
import { reportsService } from "#services/index.js";
import { serializeError } from "serialize-error";
/** @import { HttpRouteHandler } from "#root/http-server/types/http-server.js" */
const MAX_CONCURRENT_PARSE_CLIENT = Number.parseInt(process.env.REPORT_CONCURRENT_PARSE_CLIENTS || "3", 10);
/**
@ -11,7 +13,7 @@ const MAX_CONCURRENT_PARSE_CLIENT = Number.parseInt(process.env.REPORT_CONCURREN
* Description: Принимает на вход файл отчетов в формате Excel, парсит его, проверяет связи с БД,
* отдает идентификатор на статус парсинга.
*
* @type {import("#root/http-server/types/http-server.js").HttpRouteHandler}
* @type {HttpRouteHandler}
*/
export default async (ctx) => {
const { res, searchParams } = ctx;
@ -72,4 +74,6 @@ export default async (ctx) => {
} else {
throw new BadRequestError();
}
return;
};

View File

@ -1,14 +1,16 @@
import { clients } from "#root/index.js";
import crypto from "node:crypto";
/** @import { HttpRouteHandler } from "#root/http-server/types/http-server.js" */
/**
* URL: /api/reports_status_parse
* Method: GET
* Description: Отправляет частями в формате JSON информацию о текущем статусе парсинга отчетов
*
* @type {import("#root/http-server/types/http-server.js").HttpRouteHandler}
* @type {HttpRouteHandler}
*/
export default (ctx) => {
export default async (ctx) => {
const { res } = ctx;
const clientId = crypto.randomUUID();
@ -30,4 +32,6 @@ export default (ctx) => {
clients.delete(clientId);
res.res.end();
});
return;
};

View File

@ -2,6 +2,8 @@ import { BadRequestError } from "#root/http-server/index.js";
import { reportsService } from "#root/services/reports.service.js";
import { reportsSchema } from "#schemas/report.schema.js";
/** @import { HttpRouteHandler } from "#root/http-server/types/http-server.js" */
/**
* URL: /api/reports_sync
* Method: POST
@ -16,4 +18,6 @@ export default async ({ res, data }) => {
const rows = await reportsService.syncReportsWithDatabase(payload);
res.sendJson({ data: { rows } });
return;
};

View File

@ -2,7 +2,7 @@ import { ReportModel } from "#models/index.js";
import { ReportExecutorTable, ReportTable } from "#tables/index.js";
import { UOW } from "./index.js";
/** @import { ReportColumns } from "#tables/report.table.js" */
/** @import { ReportColumns } from "#models/types.js" */
export const reportRepository = {
async getAll() {

View File

@ -4,7 +4,7 @@ export class BaseTable {
static tableName = "";
static table = new sql.Table(this.tableName);
/** @type {Record<string, sql.ISqlType & sql.IColumnOptions>} */
/** @type {Record<string, { type: (() => sql.ISqlType) | sql.ISqlType } & sql.IColumnOptions>} */
static columns = {};
/**
@ -23,7 +23,6 @@ export class BaseTable {
*/
static init(table) {
table = table || this.table;
// TODO: fix types
Object.entries(this.columns).forEach(([name, { type, ...opts }]) => table.columns.add(name, type, opts));
}