english version and minio console access

This commit is contained in:
Georgiy Syralev
2025-12-13 12:53:28 +03:00
parent 753696cc93
commit b799f278a4
47 changed files with 4386 additions and 1264 deletions

View File

@@ -70,6 +70,23 @@ app.use(express.json({ limit: '100mb' }));
app.use(express.urlencoded({ limit: '100mb', extended: true }));
app.use(passport.initialize());
// Глобальная обработка необработанных ошибок и Promise rejection — логируем и не даём молча закрывать соединение
process.on('uncaughtException', (err) => {
try {
logger.error('[Process] uncaughtException', err);
} catch (e) {
console.error('[Process] uncaughtException', err);
}
});
process.on('unhandledRejection', (reason) => {
try {
logger.error('[Process] unhandledRejection', reason);
} catch (e) {
console.error('[Process] unhandledRejection', reason);
}
});
app.get('/health', (_req, res) => {
res.json({ status: 'ok', timestamp: new Date().toISOString() });
});
@@ -182,6 +199,34 @@ app.use('/uploads/blog', express.static(path.join(__dirname, '../uploads/blog'))
app.use('/uploads/avatars', express.static(path.join(__dirname, '../uploads/avatars')));
app.use('/uploads/tickets', express.static(path.join(__dirname, '../uploads/tickets')));
// Логирование всех запросов в /api/auth (не модифицируем логику, только логируем)
app.use('/api/auth', (req, res, next) => {
const start = Date.now();
try {
logger.info('[Audit] Auth request received', {
method: req.method,
path: req.originalUrl,
ip: req.ip || req.connection.remoteAddress,
});
} catch (err) {
console.error('[Audit] Failed to log auth request received', err);
}
// Log when response finished
res.on('finish', () => {
try {
logger.info('[Audit] Auth request finished', {
method: req.method,
path: req.originalUrl,
ip: req.ip || req.connection.remoteAddress,
statusCode: res.statusCode,
durationMs: Date.now() - start,
});
} catch (err) {
console.error('[Audit] Failed to log auth request finished', err);
}
});
next();
});
app.use('/api/auth', authRoutes);
app.use('/api/auth', oauthRoutes);
app.use('/api/admin', adminRoutes);
@@ -245,6 +290,18 @@ const wss = initWebSocketServer(server);
// Установка timeout для всех запросов (120 сек = 120000 мс)
server.setTimeout(120000);
// Глобальный express error handler — логируем и возвращаем 500, не ломая сокет
app.use((err: any, _req: any, res: any, _next: any) => {
try {
logger.error('[Express] Unhandled error:', err);
} catch (e) {
console.error('[Express] Unhandled error:', err);
}
if (!res.headersSent) {
res.status(500).json({ message: 'Internal server error' });
}
});
server.listen(PORT, () => {
logger.info(`${protocolLabel} сервер запущен на порту ${PORT}`);
logger.info(`База данных: ${process.env.DATABASE_URL ? 'подключена' : 'НЕ НАСТРОЕНА'}`);