testirovanie-robot/src/index.ts
Peppa 7a85f4f8d7
All checks were successful
peppa/lint lint: success за 0с
peppa/typecheck typecheck: success за 0с
peppa/test test: success за 2с
peppa/build build: success за 1с
ci / checks (pull_request) Successful in 8s
deploy / deploy (pull_request) Successful in 3s
TR-3: слияние с TR-2 — список пользователей и блокировка входа в общем каркасе
Основная ветка получила TR-2 на отдельном каркасе (src/server.js). Страницы и адреса
остаются из TR-1; список пользователей (scrypt) и блокировка после 5 ошибок перенесены в
src/users.ts и src/auth.ts, тесты TR-2 — в test/users.test.ts по сценариям спеки auth.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-16 11:13:49 +05:00

53 lines
1.6 KiB
TypeScript
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 { createServer } from "node:http";
import * as Sentry from "@sentry/node";
import { createApp } from "./app.ts";
import { loadConfig } from "./config.ts";
import { loadUsers } from "./users.ts";
const config = loadConfig();
// Без SENTRY_DSN отправка ошибок выключена.
if (config.sentry.dsn) {
Sentry.init({
dsn: config.sentry.dsn,
release: config.sentry.release,
environment: config.sentry.environment,
// В @sentry/node 11 нет sendDefaultPii: персональные данные выключаются по категориям.
// Тело запроса входа содержит пароль, cookie — отметку о входе: не отправляем ничего.
dataCollection: {
userInfo: false,
cookies: false,
httpHeaders: false,
httpBodies: [],
urlQueryParams: false,
stackFrameVariables: false,
},
});
}
for (const warning of config.warnings) console.warn(`[config] ${warning}`);
const app = createApp({
account: config.account,
mockAuth: config.mockAuth,
users: loadUsers(config.usersFile),
sessionSecret: config.sessionSecret,
cookieSecure: config.cookieSecure,
onError: (error) => {
console.error(error);
Sentry.captureException(error);
},
});
const server = createServer((req, res) => void app(req, res));
server.listen(config.port, () => {
console.log(`Сервер слушает порт ${config.port}`);
});
for (const signal of ["SIGTERM", "SIGINT"] as const) {
process.on(signal, () => {
server.close(() => process.exit(0));
server.closeIdleConnections();
});
}