add json backup fallback
This commit is contained in:
11
server.js
11
server.js
@@ -30,15 +30,20 @@ app.locals.path = {
|
||||
//#endregion
|
||||
|
||||
|
||||
//#region Server configuration
|
||||
//#region Nesessary json files
|
||||
const jsonFiles = ['configuration.json', 'stylesheet.json'];
|
||||
for (var i = 0; i < jsonFiles.length; i++) {
|
||||
if(!fs.existsSync(`${app.locals.path.source}/models/${jsonFiles[i]}`)) {
|
||||
fs.copyFileSync(`${app.locals.path.source}/backups/${jsonFiles[i]}.temp`, `${app.locals.path.source}/models/${jsonFiles[i]}`);
|
||||
}
|
||||
}
|
||||
|
||||
app.locals.stylesheet = JSON.parse(fs.readFileSync(`${app.locals.path.source}/models/stylesheet.json`, 'utf-8'));
|
||||
app.locals.configuration = JSON.parse(fs.readFileSync(`${app.locals.path.source}/models/configuration.json`, 'utf-8'));
|
||||
app.locals.package = JSON.parse(fs.readFileSync(`${app.locals.path.root}/package.json`, 'utf-8'));
|
||||
|
||||
app.locals.startMenuItems = [ ];
|
||||
|
||||
|
||||
|
||||
(async () => {
|
||||
// const server = https.createServer({
|
||||
// key: fs.readFileSync(`${app.locals.path.source}/secure/${app.locals.configuration.certificate.key}`),
|
||||
|
||||
Reference in New Issue
Block a user