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 -6
View File
@@ -1,12 +1,15 @@
const fs = require('fs-extra');
const fs = require('fs').promises;
const { existsSync, appendFileSync } = require('fs');
const path = require('path');
const logger = require('../logger');
const CARD_LOG_PATH = path.resolve(__dirname, '..', process.env.CARD_LOG_PATH);
const initCardLogs = async () => {
try {
await fs.ensureDir(path.dirname(CARD_LOG_PATH));
if (!(await fs.pathExists(CARD_LOG_PATH))) {
await fs.mkdir(path.dirname(CARD_LOG_PATH), { recursive: true });
try {
await fs.access(CARD_LOG_PATH);
} catch (e) {
await fs.writeFile(CARD_LOG_PATH, '');
logger.info(`Card log file created at: ${CARD_LOG_PATH}`);
}
@@ -31,10 +34,10 @@ const cardEvent = (req, res) => {
const logLine = `[${new Date(timestamp).toISOString()}] [${event}] UID: ${uid}\n`;
try {
if (!fs.existsSync(CARD_LOG_PATH)) {
if (!existsSync(CARD_LOG_PATH)) {
initCardLogs();
}
fs.appendFileSync(CARD_LOG_PATH, logLine);
appendFileSync(CARD_LOG_PATH, logLine);
logger.info('[CARD EVENT] Log written to:', CARD_LOG_PATH);
return res.status(200).json({ message: 'OK', path: CARD_LOG_PATH });
@@ -49,7 +52,9 @@ const cardEvent = (req, res) => {
};
const getCardLogs = async (req, res) => {
try {
if (!(await fs.pathExists(CARD_LOG_PATH))) {
try {
await fs.access(CARD_LOG_PATH);
} catch (e) {
await initCardLogs();
return res.status(200).type('text/plain').send('Card logs initialized');
}