server/src/main.js
2025-05-13 08:19:00 +03:00

28 lines
782 B
JavaScript
Executable file
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.

#!/bin/node
import fs from 'fs'
import path from 'path'
import process from 'process'
const Config = {
PORT: 8000,
DB: path.resolve(process.cwd(), 'db'),
WWW: path.resolve(process.cwd(), 'www')
}
if (fs.existsSync('config.json')) {
console.log('Найден файл config.json')
let json = JSON.parse(fs.readFileSync('config.json'));
Config.PORT = json.PORT || Config.PORT
Config.DB = json.DB || Config.DB
Config.WWW = json.WWW || Config.WWW
}
else
console.log('Файл config.json не найден. Конфигурация по умолчанию.')
console.log(`Порт: ${Config.PORT}`)
console.log(`База данных: ${Config.DB}`)
console.log(`Веб-контент: ${Config.WWW}`)
fs.writeFileSync('config.json', JSON.stringify(Config, null, 2))