Prettied all js in src/

This commit is contained in:
mrfry 2020-10-01 14:44:24 +02:00
parent 3f081d8dff
commit ee0f0a9f3b
17 changed files with 1012 additions and 688 deletions

View file

@ -12,7 +12,7 @@ CreateDB()
authDB.close()
function CreateDB () {
function CreateDB() {
const dbStruct = utils.ReadJSON(dbStructPath)
// authDB = dbtools.GetDB(':memory:')
authDB = dbtools.GetDB(usersDBPath)
@ -20,7 +20,12 @@ function CreateDB () {
Object.keys(dbStruct).forEach((tableName) => {
const tableData = dbStruct[tableName]
dbtools.CreateTable(authDB, tableName, tableData.tableStruct, tableData.foreignKey)
dbtools.CreateTable(
authDB,
tableName,
tableData.tableStruct,
tableData.foreignKey
)
})
try {
@ -28,14 +33,16 @@ function CreateDB () {
const uids = utils.ReadFile('./ids').split('\n')
uids.forEach((cid, i) => {
if (!cid) { return }
if (!cid) {
return
}
logger.Log(`[ ${i} / ${uids.length} ]`)
try {
dbtools.Insert(authDB, 'users', {
pw: uuidv4(),
oldCID: cid,
avaiblePWRequests: 4,
created: utils.GetDateString()
created: utils.GetDateString(),
})
} catch (e) {
logger.Log('Error during inserting', logger.GetColor('redbg'))
@ -52,10 +59,13 @@ function CreateDB () {
Object.keys(dbStruct).forEach((key) => {
const path = `${dir}/${key}.json`
logger.Log(`Writing ${path}...`)
utils.WriteFile(JSON.stringify({
tableInfo: dbtools.TableInfo(authDB, key),
tableRows: dbtools.SelectAll(authDB, key)
}), path)
utils.WriteFile(
JSON.stringify({
tableInfo: dbtools.TableInfo(authDB, key),
tableRows: dbtools.SelectAll(authDB, key),
}),
path
)
})
logger.Log('Done')