mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
added bit more advanced file existance checking, removed vhosts in favor or routes
This commit is contained in:
parent
ba89f4a342
commit
113a114821
24 changed files with 2720 additions and 2474 deletions
|
@ -63,6 +63,19 @@ function BackupDB(usersDbBackupPath: string, userDB: Database) {
|
|||
})
|
||||
}
|
||||
|
||||
function createDefaultUser(userDb: Database) {
|
||||
logger.Log('The user DB is empty, creating user #1', 'yellowbg')
|
||||
const pw = uuidv4()
|
||||
const insertRes = dbtools.Insert(userDb, 'users', {
|
||||
pw: pw,
|
||||
avaiblePWRequests: 0,
|
||||
created: utils.GetDateString(),
|
||||
})
|
||||
logger.Log('ID and PW for user #1: ', 'yellowbg')
|
||||
console.log(`ID: #${insertRes.lastInsertRowid}, PW: "${pw}"`)
|
||||
logger.Log('It can be also viewed from the user db file.')
|
||||
}
|
||||
|
||||
// TODO: figure out if this is needed
|
||||
// const validationTokenNameFile = 'data/validationTokenName'
|
||||
// function readValidationTokenName() {
|
||||
|
@ -83,12 +96,13 @@ function setup(data: SubmoduleData): Submodule {
|
|||
domain = domain.join('.') // "frylabs.net"
|
||||
logger.DebugLog(`Cookie domain: ${domain}`, 'cookie', 1)
|
||||
|
||||
logger.Log(
|
||||
`User count: ${dbtools
|
||||
.TableInfo(userDB, 'users')
|
||||
.dataCount.toLocaleString()} users`,
|
||||
'blue'
|
||||
)
|
||||
const userCount = dbtools
|
||||
.TableInfo(userDB, 'users')
|
||||
.dataCount.toLocaleString()
|
||||
logger.Log(`User count: ${userCount} users`, 'blue')
|
||||
if (+userCount === 0) {
|
||||
createDefaultUser(userDB)
|
||||
}
|
||||
|
||||
app.get('/avaiblePWS', (req: Request, res: any) => {
|
||||
logger.LogReq(req)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue