mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
files improvements
This commit is contained in:
@@ -125,11 +125,6 @@ function GetApp(): ModuleType {
|
|||||||
ftw.action()
|
ftw.action()
|
||||||
})
|
})
|
||||||
ftw.action()
|
ftw.action()
|
||||||
} else {
|
|
||||||
logger.Log(
|
|
||||||
`File ${ftw.fname} does not exists to watch!`,
|
|
||||||
logger.GetColor('redbg')
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -106,11 +106,6 @@ function GetApp(): ModuleType {
|
|||||||
logger.Log(`Donate URL changed: ${newData.replace(/\/n/g, '')}`)
|
logger.Log(`Donate URL changed: ${newData.replace(/\/n/g, '')}`)
|
||||||
loadDonateURL()
|
loadDonateURL()
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
logger.Log(
|
|
||||||
`Couldnt read links file! (${linksFile})`,
|
|
||||||
logger.GetColor('redbg')
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
@@ -259,6 +259,7 @@ Object.keys(modules).forEach(function (key) {
|
|||||||
)
|
)
|
||||||
app.use(module.route, module.app)
|
app.use(module.route, module.app)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
logger.Log(`Error setting up submodule: ${module.name}`, 'redbg')
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -5,6 +5,7 @@ import {
|
|||||||
PeersInfoSchema,
|
PeersInfoSchema,
|
||||||
ModulesSchema,
|
ModulesSchema,
|
||||||
SelfInfoSchema,
|
SelfInfoSchema,
|
||||||
|
LinksSchema,
|
||||||
} from '../types/typeSchemas'
|
} from '../types/typeSchemas'
|
||||||
import logger from './logger'
|
import logger from './logger'
|
||||||
import utils from './utils'
|
import utils from './utils'
|
||||||
@@ -15,8 +16,9 @@ type FileDescriptor = {
|
|||||||
path: string
|
path: string
|
||||||
schema?: Schema
|
schema?: Schema
|
||||||
defaultValue?: string
|
defaultValue?: string
|
||||||
shouldBe?: string
|
|
||||||
description?: string
|
description?: string
|
||||||
|
errorIfMissing?: boolean
|
||||||
|
warningIfMissing?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validateFiles = (): boolean => {
|
export const validateFiles = (): boolean => {
|
||||||
@@ -29,16 +31,24 @@ export const validateFiles = (): boolean => {
|
|||||||
fileExists = true
|
fileExists = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.shouldBe && !fileExists) {
|
if (file.errorIfMissing && !fileExists) {
|
||||||
const errMsg = [`File "${file.path}" does not exist! (${key})`]
|
const errMsg = [`File "${file.path}" does not exist! (${key})`]
|
||||||
if (file.shouldBe) {
|
if (file.description) {
|
||||||
errMsg.push(`Should be: ${file.shouldBe}`)
|
errMsg.push(`Should be: ${file.description}`)
|
||||||
}
|
}
|
||||||
logger.Log(errMsg.join(' '), 'redbg')
|
logger.Log(errMsg.join(' '), 'redbg')
|
||||||
everythingValid = false
|
everythingValid = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file.warningIfMissing && !fileExists) {
|
||||||
|
const warningMsg = [`File "${file.path}" does not exist! (${key})`]
|
||||||
|
if (file.description) {
|
||||||
|
warningMsg.push(`Should be: ${file.description}`)
|
||||||
|
}
|
||||||
|
logger.Log(warningMsg.join(' '), 'yellowbg')
|
||||||
|
}
|
||||||
|
|
||||||
if (file.schema && fileExists) {
|
if (file.schema && fileExists) {
|
||||||
const val = utils.ReadJSON(file.path)
|
const val = utils.ReadJSON(file.path)
|
||||||
if (!isJsonValidAndLogError(val, file.schema, file.path)) {
|
if (!isJsonValidAndLogError(val, file.schema, file.path)) {
|
||||||
@@ -71,43 +81,51 @@ export const files = {
|
|||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
serverPath: {
|
serverPath: {
|
||||||
path: 'dist/server.js',
|
path: 'dist/server.js',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'server main entry file, created after running "npm run build"',
|
'server main entry file, created after running "npm run build"',
|
||||||
},
|
},
|
||||||
qminingPageDir: {
|
qminingPageDir: {
|
||||||
path: 'submodules/qmining-page',
|
path: 'submodules/qmining-page',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'qmining page submodule directory, created by pulling submodules / setup script',
|
'qmining page submodule directory, created by pulling submodules / setup script',
|
||||||
},
|
},
|
||||||
qminingIndexPath: {
|
qminingIndexPath: {
|
||||||
path: 'nextStatic/qminingPagePublic/index.html',
|
path: 'nextStatic/qminingPagePublic/index.html',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'qmining page-s build index.html, created by "npm run build" in qmining page submodule dir',
|
'qmining page-s build index.html, created by "npm run build" in qmining page submodule dir',
|
||||||
},
|
},
|
||||||
dataEditorPageDir: {
|
dataEditorPageDir: {
|
||||||
path: 'submodules/qmining-data-editor',
|
path: 'submodules/qmining-data-editor',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'qmining data editor page submodule directory, created by pulling submodules / setup script',
|
'qmining data editor page submodule directory, created by pulling submodules / setup script',
|
||||||
},
|
},
|
||||||
dataEditorIndexPath: {
|
dataEditorIndexPath: {
|
||||||
path: 'nextStatic/dataEditorPublic/index.html',
|
path: 'nextStatic/dataEditorPublic/index.html',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'qmining data editor-s build index.html, created by "npm run build" in qmining data editor submodule dir',
|
'qmining data editor-s build index.html, created by "npm run build" in qmining data editor submodule dir',
|
||||||
},
|
},
|
||||||
moodleTestUserscriptDir: {
|
moodleTestUserscriptDir: {
|
||||||
path: 'submodules/moodle-test-userscript',
|
path: 'submodules/moodle-test-userscript',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'moodle test userscript submodule directory, created by pulling submodules / setup script',
|
'moodle test userscript submodule directory, created by pulling submodules / setup script',
|
||||||
},
|
},
|
||||||
moodleTestUserscriptPath: {
|
moodleTestUserscriptPath: {
|
||||||
path: 'submodules/moodle-test-userscript/stable.user.js',
|
path: 'submodules/moodle-test-userscript/stable.user.js',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'moodle test userscript file, created by pulling submodules / setup script',
|
'moodle test userscript file, created by pulling submodules / setup script',
|
||||||
},
|
},
|
||||||
|
|
||||||
domainFile: {
|
domainFile: {
|
||||||
path: 'data/domain',
|
path: 'data/domain',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'server domain for cookies and stuff, for ex.: "frylabs.net", no "http://" and things like that, just the domain',
|
'server domain for cookies and stuff, for ex.: "frylabs.net", no "http://" and things like that, just the domain',
|
||||||
},
|
},
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
@@ -156,10 +174,12 @@ export const files = {
|
|||||||
rootRedirectToFile: {
|
rootRedirectToFile: {
|
||||||
path: 'data/apiRootRedirectTo',
|
path: 'data/apiRootRedirectTo',
|
||||||
description: 'url to redirect users trying to acces root api path',
|
description: 'url to redirect users trying to acces root api path',
|
||||||
|
warningIfMissing: true,
|
||||||
},
|
},
|
||||||
modulesFile: {
|
modulesFile: {
|
||||||
path: './src/modules.json',
|
path: './src/modules.json',
|
||||||
shouldBe: 'module files for server',
|
errorIfMissing: true,
|
||||||
|
description: 'module files for server',
|
||||||
schema: ModulesSchema,
|
schema: ModulesSchema,
|
||||||
},
|
},
|
||||||
extraModulesFile: {
|
extraModulesFile: {
|
||||||
@@ -169,14 +189,16 @@ export const files = {
|
|||||||
},
|
},
|
||||||
statExcludeFile: {
|
statExcludeFile: {
|
||||||
path: './data/statExclude.json',
|
path: './data/statExclude.json',
|
||||||
shouldBe:
|
errorIfMissing: true,
|
||||||
|
description:
|
||||||
'array of strings which if included in requests url-s then the request itself is not counted in stats',
|
'array of strings which if included in requests url-s then the request itself is not counted in stats',
|
||||||
defaultValue: JSON.stringify([]),
|
defaultValue: JSON.stringify([]),
|
||||||
schema: { type: 'array', items: { type: 'string' } },
|
schema: { type: 'array', items: { type: 'string' } },
|
||||||
},
|
},
|
||||||
usersDBPath: {
|
usersDBPath: {
|
||||||
path: './data/dbs/users.db',
|
path: './data/dbs/users.db',
|
||||||
shouldBe: 'users sqlite db file',
|
errorIfMissing: true,
|
||||||
|
description: 'users sqlite db file',
|
||||||
},
|
},
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
@@ -189,6 +211,12 @@ export const files = {
|
|||||||
description:
|
description:
|
||||||
'test users, recieved data from them wont get added to question dbs',
|
'test users, recieved data from them wont get added to question dbs',
|
||||||
},
|
},
|
||||||
|
linksFile: {
|
||||||
|
path: 'data/links.json',
|
||||||
|
schema: LinksSchema,
|
||||||
|
description: 'file containing links, for ex.: patreon and paypal',
|
||||||
|
warningIfMissing: true,
|
||||||
|
},
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
// log files
|
// log files
|
||||||
|
Submodule submodules/qmining-data-editor updated: e17bbe6402...89edf86099
Submodule submodules/qmining-page updated: d94bf74663...509aff7cdd
Reference in New Issue
Block a user