mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
prettier 4 tabwidth
This commit is contained in:
parent
00ec614f1d
commit
96b413a365
42 changed files with 7034 additions and 6905 deletions
|
@ -1,6 +1,6 @@
|
|||
module.exports = {
|
||||
trailingComma: 'es5',
|
||||
tabWidth: 2,
|
||||
tabWidth: 4,
|
||||
semi: false,
|
||||
singleQuote: true,
|
||||
arrowParens: 'always',
|
||||
|
|
|
@ -81,7 +81,9 @@ export default function (options: Options): any {
|
|||
logger.LogStat(
|
||||
req.url,
|
||||
hostname,
|
||||
req.session && req.session.user ? req.session.user.id : 'NOUSER'
|
||||
req.session && req.session.user
|
||||
? req.session.user.id
|
||||
: 'NOUSER'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -178,7 +178,9 @@ function setup(data: SubmoduleData): void {
|
|||
}
|
||||
dbtools.Insert(msgDB, 'msgs', msgObj)
|
||||
if (userid !== parseInt(reciever)) {
|
||||
io.sockets.in(reciever.toString()).emit('chat message', msgObj)
|
||||
io.sockets
|
||||
.in(reciever.toString())
|
||||
.emit('chat message', msgObj)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -234,7 +236,9 @@ function setup(data: SubmoduleData): void {
|
|||
})
|
||||
})
|
||||
|
||||
app.post('/postfeedback', function (req: Request<{ content: string }>, res) {
|
||||
app.post(
|
||||
'/postfeedback',
|
||||
function (req: Request<{ content: string }>, res) {
|
||||
logger.LogReq(req)
|
||||
const user: User = req.session.user
|
||||
const { content } = req.body
|
||||
|
@ -255,7 +259,8 @@ function setup(data: SubmoduleData): void {
|
|||
|
||||
res.json({ success: true })
|
||||
io.sockets.in('1').emit('chat message', msgObj)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
app.get('/hasNewMsg', (req: Request, res) => {
|
||||
const user: User = req.session.user
|
||||
|
|
|
@ -116,11 +116,11 @@ function addReaction(
|
|||
}
|
||||
if (isDelete) {
|
||||
if (obj[index].reacts[reaction]) {
|
||||
obj[index].reacts[reaction] = obj[index].reacts[reaction].filter(
|
||||
(currUid: number) => {
|
||||
obj[index].reacts[reaction] = obj[index].reacts[
|
||||
reaction
|
||||
].filter((currUid: number) => {
|
||||
return uid !== currUid
|
||||
}
|
||||
)
|
||||
})
|
||||
if (obj[index].reacts[reaction].length === 0) {
|
||||
delete obj[index].reacts[reaction]
|
||||
}
|
||||
|
@ -184,7 +184,8 @@ function getPostData(
|
|||
}
|
||||
|
||||
function setup(data: SubmoduleData): void {
|
||||
const { app, /* userDB, url, */ publicdirs /*, moduleSpecificData */ } = data
|
||||
const { app, /* userDB, url, */ publicdirs /*, moduleSpecificData */ } =
|
||||
data
|
||||
|
||||
const publicDir = publicdirs[0]
|
||||
|
||||
|
@ -209,7 +210,9 @@ function setup(data: SubmoduleData): void {
|
|||
const { forumPath, contents } = getForumData(forumName, forumDir)
|
||||
|
||||
const from = req.query.from || Object.keys(contents).reverse()[0]
|
||||
const count = parseInt(req.query.count ? req.query.count.toString() : '5')
|
||||
const count = parseInt(
|
||||
req.query.count ? req.query.count.toString() : '5'
|
||||
)
|
||||
const getContent = req.query.getContent
|
||||
|
||||
let entries = {}
|
||||
|
@ -414,7 +417,10 @@ function setup(data: SubmoduleData): void {
|
|||
if (contents[postKey] && contents[postKey].user === user.id) {
|
||||
utils.deleteFile(forumPath + '/' + postKey)
|
||||
delete contents[postKey]
|
||||
utils.WriteFile(JSON.stringify(contents, null, 2), contentFilePath)
|
||||
utils.WriteFile(
|
||||
JSON.stringify(contents, null, 2),
|
||||
contentFilePath
|
||||
)
|
||||
|
||||
res.json({ success: true, deletedId: postKey })
|
||||
} else {
|
||||
|
@ -466,7 +472,11 @@ function setup(data: SubmoduleData): void {
|
|||
return
|
||||
}
|
||||
|
||||
const { postPath, postData } = getPostData(postKey, contents, forumPath)
|
||||
const { postPath, postData } = getPostData(
|
||||
postKey,
|
||||
contents,
|
||||
forumPath
|
||||
)
|
||||
if (!postData) {
|
||||
res.json({
|
||||
success: false,
|
||||
|
@ -488,7 +498,11 @@ function setup(data: SubmoduleData): void {
|
|||
addComment(postData.comments, path, comment)
|
||||
} else if (type === 'delete') {
|
||||
if (postData.comments) {
|
||||
const success = deleteComment(postData.comments, path, user.id)
|
||||
const success = deleteComment(
|
||||
postData.comments,
|
||||
path,
|
||||
user.id
|
||||
)
|
||||
if (!success) {
|
||||
res.json({
|
||||
success: false,
|
||||
|
@ -542,7 +556,11 @@ function setup(data: SubmoduleData): void {
|
|||
return
|
||||
}
|
||||
|
||||
const { postPath, postData } = getPostData(postKey, contents, forumPath)
|
||||
const { postPath, postData } = getPostData(
|
||||
postKey,
|
||||
contents,
|
||||
forumPath
|
||||
)
|
||||
if (!postData) {
|
||||
res.json({
|
||||
success: false,
|
||||
|
@ -554,11 +572,11 @@ function setup(data: SubmoduleData): void {
|
|||
if (postData) {
|
||||
if (isDelete) {
|
||||
if (postData.reacts) {
|
||||
postData.reacts[reaction] = postData.reacts[reaction].filter(
|
||||
(uid) => {
|
||||
postData.reacts[reaction] = postData.reacts[
|
||||
reaction
|
||||
].filter((uid) => {
|
||||
return uid !== user.id
|
||||
}
|
||||
)
|
||||
})
|
||||
if (postData.reacts[reaction].length === 0) {
|
||||
delete postData.reacts[reaction]
|
||||
}
|
||||
|
@ -568,7 +586,9 @@ function setup(data: SubmoduleData): void {
|
|||
postData.reacts = { [reaction]: [user.id] }
|
||||
} else {
|
||||
if (Array.isArray(postData.reacts[reaction])) {
|
||||
if (!postData.reacts[reaction].includes(user.id)) {
|
||||
if (
|
||||
!postData.reacts[reaction].includes(user.id)
|
||||
) {
|
||||
postData.reacts[reaction].push(user.id)
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -244,9 +244,11 @@ function getResult(data: {
|
|||
).filter((x) => {
|
||||
return !searchIn.includes(x)
|
||||
})
|
||||
searchInDbs(question, subj, searchInMore, testUrl).then((res) => {
|
||||
searchInDbs(question, subj, searchInMore, testUrl).then(
|
||||
(res) => {
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
)
|
||||
} else {
|
||||
resolve(res)
|
||||
}
|
||||
|
@ -587,7 +589,13 @@ function setup(data: SubmoduleData): Submodule {
|
|||
if (suitedQuestionDbs.length === 0) {
|
||||
if (!dbExists(location, questionDbs)) {
|
||||
suitedQuestionDbs.push(
|
||||
getNewQdb(location, maxIndex, dbsFile, publicDir, questionDbs)
|
||||
getNewQdb(
|
||||
location,
|
||||
maxIndex,
|
||||
dbsFile,
|
||||
publicDir,
|
||||
questionDbs
|
||||
)
|
||||
)
|
||||
} else {
|
||||
logger.Log(
|
||||
|
@ -608,9 +616,12 @@ function setup(data: SubmoduleData): Submodule {
|
|||
.then((resultArray: Array<Result>) => {
|
||||
logResult(req.body, resultArray, user.id, dryRun)
|
||||
|
||||
const totalNewQuestions = resultArray.reduce((acc, sres) => {
|
||||
const totalNewQuestions = resultArray.reduce(
|
||||
(acc, sres) => {
|
||||
return acc + sres.newQuestions.length
|
||||
}, 0)
|
||||
},
|
||||
0
|
||||
)
|
||||
|
||||
res.json({
|
||||
success: resultArray.length > 0,
|
||||
|
@ -670,16 +681,15 @@ function setup(data: SubmoduleData): Submodule {
|
|||
writeAskData(req.body)
|
||||
|
||||
// every question in a different thread
|
||||
const resultPromises: Promise<DbSearchResult>[] = req.body.questions.map(
|
||||
(question: Question) => {
|
||||
const resultPromises: Promise<DbSearchResult>[] =
|
||||
req.body.questions.map((question: Question) => {
|
||||
return getResult({
|
||||
question: question,
|
||||
subj: subj,
|
||||
testUrl: testUrl,
|
||||
questionDbs: questionDbs,
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
Promise.all(resultPromises).then((results: DbSearchResult[]) => {
|
||||
const response = results.map((result: DbSearchResult) => {
|
||||
|
@ -943,7 +953,10 @@ function setup(data: SubmoduleData): Submodule {
|
|||
`${date}: User ${user.id} deleted a question from '${subjName}' (index: ${index})`,
|
||||
dataEditsLog
|
||||
)
|
||||
utils.AppendToFile(JSON.stringify(deletedQuestion, null, 2), dataEditsLog)
|
||||
utils.AppendToFile(
|
||||
JSON.stringify(deletedQuestion, null, 2),
|
||||
dataEditsLog
|
||||
)
|
||||
}
|
||||
|
||||
if (editType === 'edit') {
|
||||
|
|
|
@ -107,7 +107,10 @@ function setup(data: SubmoduleData): void {
|
|||
}
|
||||
}
|
||||
|
||||
logger.Log(`Vote from #${user.id}: ${key}: ${val}`, logger.GetColor('blue'))
|
||||
logger.Log(
|
||||
`Vote from #${user.id}: ${key}: ${val}`,
|
||||
logger.GetColor('blue')
|
||||
)
|
||||
res.render('votethank', {
|
||||
result: prevVote ? 'already voted' : 'success',
|
||||
prevVote: prevVote,
|
||||
|
|
|
@ -90,9 +90,16 @@ function setup(data: SubmoduleData): void {
|
|||
} else {
|
||||
result[userId] = {
|
||||
count: uidRes.count + userStat.count,
|
||||
newQuestions: uidRes.newQuestions + userStat.newQuestions,
|
||||
allQuestions: uidRes.allQuestions + userStat.allQuestions,
|
||||
subjs: mergeObjSum(uidRes.subjs, userStat.subjs),
|
||||
newQuestions:
|
||||
uidRes.newQuestions +
|
||||
userStat.newQuestions,
|
||||
allQuestions:
|
||||
uidRes.allQuestions +
|
||||
userStat.allQuestions,
|
||||
subjs: mergeObjSum(
|
||||
uidRes.subjs,
|
||||
userStat.subjs
|
||||
),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -65,7 +65,9 @@ function listDir(publicDir: string, subdir: string, userFilesDir: string) {
|
|||
date: stat.mtime.getTime(),
|
||||
user: users && users[file] ? users[file].uid : -1,
|
||||
views:
|
||||
users && users[file] && users[file].views ? users[file].views : 0,
|
||||
users && users[file] && users[file].views
|
||||
? users[file].views
|
||||
: 0,
|
||||
upvotes:
|
||||
users && users[file] && users[file].upvotes
|
||||
? users[file].upvotes
|
||||
|
@ -95,7 +97,8 @@ function setup(data: SubmoduleData): void {
|
|||
const x = safePath.split('/')
|
||||
const dir = x[2]
|
||||
const fname = x.pop()
|
||||
const dataFilePath = userFilesDir + '/' + dir + '/' + dataFileName
|
||||
const dataFilePath =
|
||||
userFilesDir + '/' + dir + '/' + dataFileName
|
||||
|
||||
const data = utils.ReadJSON(dataFilePath)
|
||||
|
||||
|
@ -250,7 +253,8 @@ function setup(data: SubmoduleData): void {
|
|||
logger.GetColor('blue')
|
||||
)
|
||||
|
||||
const usersFile = userFilesDir + '/' + safeDir + '/' + dataFileName
|
||||
const usersFile =
|
||||
userFilesDir + '/' + safeDir + '/' + dataFileName
|
||||
const users = utils.ReadJSON(usersFile)
|
||||
users[body.fileName] = { uid: user.id }
|
||||
utils.WriteFile(JSON.stringify(users), usersFile)
|
||||
|
|
|
@ -163,7 +163,8 @@ function setup(data: SubmoduleData): Submodule {
|
|||
})
|
||||
.sort((a: Session, b: Session) => {
|
||||
return (
|
||||
new Date(a.lastAccess).getTime() - new Date(b.lastAccess).getTime()
|
||||
new Date(a.lastAccess).getTime() -
|
||||
new Date(b.lastAccess).getTime()
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
@ -53,7 +53,10 @@ function GetApp(): ModuleType {
|
|||
auth({
|
||||
userDB: userDB,
|
||||
jsonResponse: false,
|
||||
exceptions: ['/favicon.ico', '/img/frylabs-logo_large_transparent.png'],
|
||||
exceptions: [
|
||||
'/favicon.ico',
|
||||
'/img/frylabs-logo_large_transparent.png',
|
||||
],
|
||||
})
|
||||
)
|
||||
app.use((req: Request, _res, next) => {
|
||||
|
@ -180,7 +183,11 @@ function GetApp(): ModuleType {
|
|||
if (!redirect.nolog) {
|
||||
logger.LogReq(req)
|
||||
}
|
||||
logger.DebugLog(`Qmining module ${redirect.from} redirect`, 'infos', 1)
|
||||
logger.DebugLog(
|
||||
`Qmining module ${redirect.from} redirect`,
|
||||
'infos',
|
||||
1
|
||||
)
|
||||
|
||||
let target = redirect.to
|
||||
if (!redirect.to.includes('https://')) {
|
||||
|
|
|
@ -15,7 +15,7 @@ const res = data.reduce((acc, val) => {
|
|||
if (formattedVal.startsWith('#')) return acc
|
||||
if (formattedVal.startsWith('Q')) {
|
||||
currVal = {
|
||||
Q: formattedVal
|
||||
Q: formattedVal,
|
||||
}
|
||||
return acc
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ const res = data.reduce((acc, val) => {
|
|||
{
|
||||
...currVal,
|
||||
data: {
|
||||
type: 'simple'
|
||||
}
|
||||
}
|
||||
type: 'simple',
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -82,16 +82,22 @@ if (stat.isDirectory()) {
|
|||
clearPossibleAnswers(pathA, db)
|
||||
|
||||
log(
|
||||
`Cleared possible questions from ${C('green')}${pathA}${C()} based on ${C(
|
||||
`Cleared possible questions from ${C(
|
||||
'green'
|
||||
)}${pathB}${C()} db`
|
||||
)}${pathA}${C()} based on ${C('green')}${pathB}${C()} db`
|
||||
)
|
||||
} else {
|
||||
log(
|
||||
`Removing possible question duplicates from ${C('green')}${pathA}${C()}`
|
||||
`Removing possible question duplicates from ${C(
|
||||
'green'
|
||||
)}${pathA}${C()}`
|
||||
)
|
||||
removePossibleAnswersDuplicates(pathA)
|
||||
log(`Removed possible question duplicates from ${C('green')}${pathA}${C()}`)
|
||||
log(
|
||||
`Removed possible question duplicates from ${C(
|
||||
'green'
|
||||
)}${pathA}${C()}`
|
||||
)
|
||||
}
|
||||
} else {
|
||||
console.time('load')
|
||||
|
@ -309,9 +315,11 @@ function difference({ dbA, dbB }) {
|
|||
|
||||
hr()
|
||||
log(
|
||||
`${C('blue')}${i + 1} / ${dbA.length}: ${C('green')}${subj.Name}, ${C(
|
||||
'blue'
|
||||
)}${subj.Questions.length}${C('green')} questions${C()}`
|
||||
`${C('blue')}${i + 1} / ${dbA.length}: ${C('green')}${
|
||||
subj.Name
|
||||
}, ${C('blue')}${subj.Questions.length}${C(
|
||||
'green'
|
||||
)} questions${C()}`
|
||||
)
|
||||
|
||||
printProgressBar(i + 1, dbA.length)
|
||||
|
|
|
@ -201,18 +201,20 @@ function processIncomingRequestUsingDb(
|
|||
.then((results: Array<WorkerResult>) => {
|
||||
const allQuestions: Question[] = [] // all new questions here that do not have result
|
||||
results.forEach((result: WorkerResult, i) => {
|
||||
const add = (result.result as SearchResultQuestion[]).every(
|
||||
(res: SearchResultQuestion) => {
|
||||
const add = (
|
||||
result.result as SearchResultQuestion[]
|
||||
).every((res: SearchResultQuestion) => {
|
||||
return res.match < minMatchAmmountToAdd
|
||||
}
|
||||
)
|
||||
})
|
||||
if (add && !result.error) {
|
||||
allQuestions.push(recievedQuestions[i])
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
const subjName = getSubjNameWithoutYear(recievedData.subj)
|
||||
const subjName = getSubjNameWithoutYear(
|
||||
recievedData.subj
|
||||
)
|
||||
if (allQuestions.length > 0) {
|
||||
addQuestionsToDb(allQuestions, subjName, qdb)
|
||||
|
||||
|
@ -224,7 +226,11 @@ function processIncomingRequestUsingDb(
|
|||
)
|
||||
if (currWrites >= writeAfter && !dryRun) {
|
||||
currWrites = 0
|
||||
logger.DebugLog('Writing data.json', 'isadding', 1)
|
||||
logger.DebugLog(
|
||||
'Writing data.json',
|
||||
'isadding',
|
||||
1
|
||||
)
|
||||
writeData(qdb.data, qdb.path)
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +245,11 @@ function processIncomingRequestUsingDb(
|
|||
logger.DebugLog('New Questions:', 'isadding', 2)
|
||||
logger.DebugLog(allQuestions, 'isadding', 2)
|
||||
|
||||
logger.DebugLog('ProcessIncomingRequest done', 'isadding', 1)
|
||||
logger.DebugLog(
|
||||
'ProcessIncomingRequest done',
|
||||
'isadding',
|
||||
1
|
||||
)
|
||||
resolve({
|
||||
newQuestions: allQuestions,
|
||||
subjName: recievedData.subj,
|
||||
|
@ -254,7 +264,9 @@ function processIncomingRequestUsingDb(
|
|||
logger.GetColor('redbg')
|
||||
)
|
||||
reject(
|
||||
new Error('Error while processing processData worker result!')
|
||||
new Error(
|
||||
'Error while processing processData worker result!'
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
|
@ -337,7 +349,8 @@ function runCleanWorker(
|
|||
msgAllWorker({
|
||||
type: 'rmQuestions',
|
||||
data: {
|
||||
questionIndexesToRemove: questionIndexesToRemove as number[][],
|
||||
questionIndexesToRemove:
|
||||
questionIndexesToRemove as number[][],
|
||||
subjIndex: subjIndex,
|
||||
qdbIndex: qdb.index,
|
||||
recievedQuestions: recievedQuesitons,
|
||||
|
@ -545,7 +558,10 @@ export function backupData(questionDbs: Array<QuestionDb>): void {
|
|||
// logger.Log(`Backing up ${data.name}...`)
|
||||
writeData(
|
||||
data.data,
|
||||
`${path}${data.name}_${utils.GetDateString(undefined, true)}.json`
|
||||
`${path}${data.name}_${utils.GetDateString(
|
||||
undefined,
|
||||
true
|
||||
)}.json`
|
||||
)
|
||||
// logger.Log('Done')
|
||||
} catch (err) {
|
||||
|
|
|
@ -166,7 +166,9 @@ function compareString(
|
|||
i++
|
||||
}
|
||||
|
||||
let percent = Math.round(parseFloat(((match / s1a.length) * 100).toFixed(2)))
|
||||
let percent = Math.round(
|
||||
parseFloat(((match / s1a.length) * 100).toFixed(2))
|
||||
)
|
||||
const lengthDifference = Math.abs(s2a.length - s1a.length)
|
||||
percent -= lengthDifference * lengthDiffMultiplier
|
||||
if (percent < 0) {
|
||||
|
@ -627,15 +629,20 @@ function setNoPossibleAnswersPenalties(
|
|||
const updated = results.map((result) => {
|
||||
const matchCount = Array.isArray(result.q.data.possibleAnswers)
|
||||
? result.q.data.possibleAnswers.filter((resultPossibleAnswer) => {
|
||||
return questionPossibleAnswers.some((questionPossibleAnswer) => {
|
||||
if (questionPossibleAnswer.val && resultPossibleAnswer.val) {
|
||||
return questionPossibleAnswers.some(
|
||||
(questionPossibleAnswer) => {
|
||||
if (
|
||||
questionPossibleAnswer.val &&
|
||||
resultPossibleAnswer.val
|
||||
) {
|
||||
return questionPossibleAnswer.val.includes(
|
||||
resultPossibleAnswer.val
|
||||
)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
}).length
|
||||
: 0
|
||||
|
||||
|
@ -648,7 +655,9 @@ function setNoPossibleAnswersPenalties(
|
|||
match: result.match - noPossibleAnswerMatchPenalty,
|
||||
detailedMatch: {
|
||||
...result.detailedMatch,
|
||||
qMatch: result.detailedMatch.qMatch - noPossibleAnswerMatchPenalty,
|
||||
qMatch:
|
||||
result.detailedMatch.qMatch -
|
||||
noPossibleAnswerMatchPenalty,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -781,7 +790,8 @@ function handleWorkerData() {
|
|||
// }done!`
|
||||
// )
|
||||
} else if (msg.type === 'dbEdit') {
|
||||
const { dbIndex, edits }: { dbIndex: number; edits: Edits } = msg.data
|
||||
const { dbIndex, edits }: { dbIndex: number; edits: Edits } =
|
||||
msg.data
|
||||
const { resultDb } = editDb(qdbs[dbIndex], edits)
|
||||
qdbs[dbIndex] = resultDb
|
||||
logger.DebugLog(`Worker db edit ${workerIndex}`, 'worker update', 1)
|
||||
|
@ -811,7 +821,10 @@ function handleWorkerData() {
|
|||
added = true
|
||||
return {
|
||||
Name: subj.Name,
|
||||
Questions: [...subj.Questions, ...newQuestions],
|
||||
Questions: [
|
||||
...subj.Questions,
|
||||
...newQuestions,
|
||||
],
|
||||
}
|
||||
} else {
|
||||
return subj
|
||||
|
@ -841,7 +854,11 @@ function handleWorkerData() {
|
|||
}
|
||||
})
|
||||
}
|
||||
logger.DebugLog(`Worker new question ${workerIndex}`, 'worker update', 1)
|
||||
logger.DebugLog(
|
||||
`Worker new question ${workerIndex}`,
|
||||
'worker update',
|
||||
1
|
||||
)
|
||||
|
||||
parentPort.postMessage({
|
||||
msg: `From thread #${workerIndex}: update done`,
|
||||
|
@ -930,7 +947,8 @@ export function cleanDb(
|
|||
|
||||
if (
|
||||
res > minMatchToNotSearchOtherSubjects &&
|
||||
(!question.data.date || question.data.date < overwriteFromDate)
|
||||
(!question.data.date ||
|
||||
question.data.date < overwriteFromDate)
|
||||
) {
|
||||
return [...acc, i]
|
||||
}
|
||||
|
|
|
@ -108,7 +108,11 @@ function LogReq(
|
|||
if (req.url.includes('lred')) {
|
||||
dl += C('red')
|
||||
}
|
||||
if (req.session && req.session.user && !shouldLog(req.session.user.id, noLogIds)) {
|
||||
if (
|
||||
req.session &&
|
||||
req.session.user &&
|
||||
!shouldLog(req.session.user.id, noLogIds)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -189,21 +193,30 @@ function Load(): void {
|
|||
try {
|
||||
uvData = JSON.parse(utils.ReadFile(uStatsFile))
|
||||
} catch (err) {
|
||||
Log('Error at loading logs! (@ first run its normal)', GetColor('redbg'))
|
||||
Log(
|
||||
'Error at loading logs! (@ first run its normal)',
|
||||
GetColor('redbg')
|
||||
)
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
try {
|
||||
udvData = JSON.parse(utils.ReadFile(uvStatsFile))
|
||||
} catch (err) {
|
||||
Log('Error at loading logs! (@ first run its normal)', GetColor('redbg'))
|
||||
Log(
|
||||
'Error at loading logs! (@ first run its normal)',
|
||||
GetColor('redbg')
|
||||
)
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
try {
|
||||
vData = utils.ReadJSON(statFile)
|
||||
} catch (err) {
|
||||
Log('Error at loading logs! (@ first run its normal)', GetColor('redbg'))
|
||||
Log(
|
||||
'Error at loading logs! (@ first run its normal)',
|
||||
GetColor('redbg')
|
||||
)
|
||||
console.error(err)
|
||||
}
|
||||
|
||||
|
@ -332,7 +345,10 @@ function Save() {
|
|||
utils.WriteFile(JSON.stringify(dvData), vStatFile)
|
||||
// Log("Stats wrote.");
|
||||
} catch (err) {
|
||||
Log('Error at writing visit logs! (more in stderr)', GetColor('redbg'))
|
||||
Log(
|
||||
'Error at writing visit logs! (more in stderr)',
|
||||
GetColor('redbg')
|
||||
)
|
||||
console.error(err)
|
||||
}
|
||||
writes = 0
|
||||
|
|
|
@ -251,7 +251,10 @@ function uploadFile(
|
|||
|
||||
file.mv(fileDestination, (err: Error) => {
|
||||
if (err) {
|
||||
logger.Log(`Unable to upload file!`, logger.GetColor('redbg'))
|
||||
logger.Log(
|
||||
`Unable to upload file!`,
|
||||
logger.GetColor('redbg')
|
||||
)
|
||||
console.error(err)
|
||||
reject(err)
|
||||
} else {
|
||||
|
|
|
@ -35,7 +35,13 @@ interface WorkerObj {
|
|||
}
|
||||
|
||||
export interface TaskObject {
|
||||
type: 'work' | 'dbEdit' | 'newQuestions' | 'newdb' | 'dbClean' | 'rmQuestions'
|
||||
type:
|
||||
| 'work'
|
||||
| 'dbEdit'
|
||||
| 'newQuestions'
|
||||
| 'newdb'
|
||||
| 'dbClean'
|
||||
| 'rmQuestions'
|
||||
data:
|
||||
| {
|
||||
searchIn: number[]
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 281d0e00ce054d46444f377876786b913b8c1a08
|
||||
Subproject commit ed507dc39f5d34703e53585a75a0138e70bcee3a
|
Loading…
Add table
Add a link
Reference in a new issue