mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
added / fixed some types
This commit is contained in:
parent
5f12284bb8
commit
bc5c293539
41 changed files with 4378 additions and 8304 deletions
|
@ -1,4 +1,5 @@
|
|||
import { v4 as uuidv4 } from 'uuid'
|
||||
import type { Database } from 'better-sqlite3'
|
||||
|
||||
import logger from '../../../utils/logger'
|
||||
import utils from '../../../utils/utils'
|
||||
|
@ -11,7 +12,15 @@ const usersDbBackupPath = 'data/dbs/backup'
|
|||
const maxPWCount = 3
|
||||
const daysAfterUserGetsPWs = 7 // days after user gets pw-s
|
||||
|
||||
function BackupDB(usersDbBackupPath, userDB) {
|
||||
interface Session {
|
||||
id: string
|
||||
userId: number
|
||||
createDate: string
|
||||
lastAccess: string
|
||||
isScript: number
|
||||
}
|
||||
|
||||
function BackupDB(usersDbBackupPath: string, userDB: Database) {
|
||||
logger.Log('Backing up auth DB ...')
|
||||
utils.CreatePath(usersDbBackupPath, true)
|
||||
userDB
|
||||
|
@ -23,7 +32,7 @@ function BackupDB(usersDbBackupPath, userDB) {
|
|||
.then(() => {
|
||||
logger.Log('Auth DB backup complete!')
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: Error) => {
|
||||
logger.Log('Auth DB backup failed!', logger.GetColor('redbg'))
|
||||
console.error(err)
|
||||
})
|
||||
|
@ -62,8 +71,7 @@ function setup(data: SubmoduleData): any {
|
|||
res.json({
|
||||
result: 'error',
|
||||
success: false,
|
||||
msg:
|
||||
'Too many passwords requested or cant request password yet, try later',
|
||||
msg: 'Too many passwords requested or cant request password yet, try later',
|
||||
})
|
||||
logger.Log(
|
||||
`User #${requestingUser.id} requested too much passwords`,
|
||||
|
@ -128,8 +136,10 @@ function setup(data: SubmoduleData): any {
|
|||
userID: user.id,
|
||||
isScript: isScript ? 1 : 0,
|
||||
})
|
||||
.sort((a, b) => {
|
||||
return new Date(a).getTime() - new Date(b).getTime()
|
||||
.sort((a: Session, b: Session) => {
|
||||
return (
|
||||
new Date(a.lastAccess).getTime() - new Date(b.lastAccess).getTime()
|
||||
)
|
||||
})
|
||||
|
||||
const diff = existingSessions.length - minimumAlowwedSessions
|
||||
|
@ -238,7 +248,7 @@ function setup(data: SubmoduleData): any {
|
|||
})
|
||||
})
|
||||
|
||||
function getDayDiff(dateString) {
|
||||
function getDayDiff(dateString: string | Date) {
|
||||
const msdiff = new Date().getTime() - new Date(dateString).getTime()
|
||||
return Math.floor(msdiff / (1000 * 3600 * 24))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue