vite_deleteelectron

This commit is contained in:
2026-08-09 21:02:10 +03:00
parent 5d2fc5773c
commit 4ba9dd8012
99 changed files with 7080 additions and 48649 deletions
+11 -8
View File
@@ -1,5 +1,6 @@
const fs = require('fs-extra');
const fs = require('fs').promises;
const cors = require('cors');
const helmet = require('helmet');
const express = require('express');
const morgan = require('morgan');
const path = require('path');
@@ -26,15 +27,15 @@ const corsConfig = require('./config/cors');
const sessionConfig = require('./config/session');
// Middleware
app.use(helmet()); // Добавление helmet для защиты
app.use(cors(corsConfig));
app.use(morgan('dev'));
app.use(express.json());
app.use(session(sessionConfig(session)));
// Роуты, которые не требуют CSRF
// Роуты
app.use('/api/auth', authRouter);
app.use(require('./middleware/csrf'));
// Статические файлы
app.use(express.static(path.join(__dirname, 'admin-frontend', 'build')));
app.use(express.static(path.join(__dirname, '..','admin-frontend', 'build')));
app.use('/uploads', express.static(__dirname + '/uploads'));
// Роуты
@@ -64,7 +65,7 @@ app.get(/.*/, (req, res, next) => {
if (req.path.startsWith('/api/') || req.path.startsWith('/moders')) {
return next();
}
res.sendFile(path.join(__dirname, 'admin-frontend', 'build', 'index.html'));
res.sendFile(path.join(__dirname, '..','admin-frontend', 'build', 'index.html'));
});
// Обработчик ошибок (должен быть последним!)
@@ -80,7 +81,8 @@ app.get('/api/status', async (req, res) => {
app.get('/api/config', async (req, res) => {
try {
const backendConfigPath = path.join(__dirname, '../backend/config.json');
const backendConfig = await fs.readJson(backendConfigPath);
const content = await fs.readFile(backendConfigPath, 'utf8');
const backendConfig = JSON.parse(content);
const config = {
payslipsPath: backendConfig.payslipsPath
};
@@ -94,7 +96,8 @@ app.get('/api/config', async (req, res) => {
app.post('/api/config', async (req, res) => {
try {
const backendConfigPath = path.join(__dirname, '../backend/config.json');
const currentConfig = await fs.readJson(backendConfigPath);
const content = await fs.readFile(backendConfigPath, 'utf8');
const currentConfig = JSON.parse(content);
// Обновляем только разрешенные поля
if (req.body.payslipsPath) {
@@ -102,7 +105,7 @@ app.post('/api/config', async (req, res) => {
}
// Сохраняем обновленный конфиг
await fs.writeJson(backendConfigPath, currentConfig, { spaces: 4 });
await fs.writeFile(backendConfigPath, JSON.stringify(currentConfig, null, 4));
res.json({
success: true,