mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Exit cleanup functions, authentication polish, db polish
This commit is contained in:
parent
fb8e12f8d2
commit
c764c4f402
10 changed files with 314 additions and 229 deletions
|
@ -11,9 +11,22 @@ let authDB
|
|||
console.clear()
|
||||
CreateDB()
|
||||
|
||||
// authDB.backup(usersDBPath)
|
||||
// .then(() => {
|
||||
// logger.Log('backup complete!')
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// logger.Log('backup failed!', logger.GetColor('redbg'))
|
||||
// console.log(err)
|
||||
// })
|
||||
|
||||
authDB.close()
|
||||
|
||||
function CreateDB () {
|
||||
const dbStruct = utils.ReadJSON(dbStructPath)
|
||||
// authDB = dbtools.GetDB(':memory:')
|
||||
authDB = dbtools.GetDB(usersDBPath)
|
||||
authDB.pragma('synchronous = OFF')
|
||||
|
||||
Object.keys(dbStruct).forEach((tableName) => {
|
||||
const tableData = dbStruct[tableName]
|
||||
|
@ -24,11 +37,14 @@ function CreateDB () {
|
|||
const uids = utils.ReadFile('../dbUsers/keys').split('\n')
|
||||
|
||||
uids.forEach((cid, i) => {
|
||||
if (!cid) { return }
|
||||
logger.Log(`[ ${i} / ${uids.length} ]`)
|
||||
try {
|
||||
dbtools.Insert(authDB, 'users', {
|
||||
pw: uuidv4(),
|
||||
oldCID: cid
|
||||
oldCID: cid,
|
||||
avaiblePWRequests: 4,
|
||||
created: new Date().toString()
|
||||
})
|
||||
} catch (e) {
|
||||
logger.Log('Error during inserting', logger.GetColor('redbg'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue