mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
readme update, updated some queries to use numbers instead of strings
This commit is contained in:
parent
088a3785cc
commit
f8a7c6a4e5
14 changed files with 53 additions and 62 deletions
|
@ -52,7 +52,6 @@ function renderLogin(req: Request, res: Response) {
|
|||
})
|
||||
} else {
|
||||
res.render('login', {
|
||||
useHttp: process.env.NS_NO_HTTPS_FORCE,
|
||||
domain: constants.domain,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -60,9 +60,9 @@ function GetApp(): ModuleType {
|
|||
throw new Error(`No public dir! ( API )`)
|
||||
}
|
||||
|
||||
let domain: any = url.split('.') // [ "https://api", "frylabs", "net" ]
|
||||
domain.shift() // [ "frylabs", "net" ]
|
||||
domain = domain.join('.') // "frylabs.net"
|
||||
let domain: any = url.split('.')
|
||||
domain.shift()
|
||||
domain = domain.join('.') // "qmining.com"
|
||||
logger.DebugLog(`Cookie domain: ${domain}`, 'cookie', 1)
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -40,8 +40,8 @@ const daysAfterUserGetsPWs = 7 // days after user gets pw-s
|
|||
interface Session {
|
||||
id: string
|
||||
userId: number
|
||||
createDate: string
|
||||
lastAccess: string
|
||||
createDate: number
|
||||
lastAccess: number
|
||||
isScript: number
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ function createDefaultUser(userDb: Database) {
|
|||
const insertRes = dbtools.Insert(userDb, 'users', {
|
||||
pw: pw,
|
||||
avaiblePWRequests: 50,
|
||||
created: utils.GetDateString(),
|
||||
created: new Date().getTime(),
|
||||
})
|
||||
logger.Log('ID and PW for user #1: ', 'yellowbg')
|
||||
console.log(`ID: #${insertRes.lastInsertRowid}, PW: "${pw}"`)
|
||||
|
@ -153,7 +153,7 @@ function setup(data: SubmoduleData): Submodule {
|
|||
const insertRes = dbtools.Insert(userDB, 'users', {
|
||||
pw: pw,
|
||||
avaiblePWRequests: 0,
|
||||
created: utils.GetDateString(),
|
||||
created: new Date().getTime(),
|
||||
createdBy: requestingUser.id,
|
||||
})
|
||||
|
||||
|
@ -194,10 +194,7 @@ function setup(data: SubmoduleData): Submodule {
|
|||
isScript: isScript ? 1 : 0,
|
||||
})
|
||||
.sort((a: Session, b: Session) => {
|
||||
return (
|
||||
new Date(a.lastAccess).getTime() -
|
||||
new Date(b.lastAccess).getTime()
|
||||
)
|
||||
return a.lastAccess - b.lastAccess
|
||||
})
|
||||
|
||||
const diff = existingSessions.length - minimumAlowwedSessions
|
||||
|
@ -222,7 +219,7 @@ function setup(data: SubmoduleData): Submodule {
|
|||
'users',
|
||||
{
|
||||
loginCount: user.loginCount + 1,
|
||||
lastLogin: utils.GetDateString(),
|
||||
lastLogin: new Date().getTime(),
|
||||
},
|
||||
{
|
||||
id: user.id,
|
||||
|
@ -233,7 +230,7 @@ function setup(data: SubmoduleData): Submodule {
|
|||
id: sessionID,
|
||||
userID: user.id,
|
||||
isScript: isScript ? 1 : 0,
|
||||
createDate: utils.GetDateString(),
|
||||
createDate: new Date().getTime(),
|
||||
})
|
||||
|
||||
// https://www.npmjs.com/package/cookie
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
button.classList.add('disabledButton')
|
||||
button.disabled = true
|
||||
// TODO: get url from controller
|
||||
const rawResponse = await fetch('<%= useHttp ? `http://${domain}/api/login` : `https://${domain}/api/login` %>', {
|
||||
const rawResponse = await fetch('/api/login', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/bash
|
||||
scp -P 19192 qminer@megacarrot.frylabs.net:/home/qminer/mrfrys-node-server/stats/idstats "./idstats.new"
|
||||
scp -P 19192 qminer@megacarrot.frylabs.net:/home/qminer/old.nodeServ/stats/idstats "./idstats.old"
|
||||
|
||||
cat idstats.new | jq 'keys' > idstats.new.keys
|
||||
cat idstats.old | jq 'keys' > idstats.old.keys
|
||||
|
||||
cat idstats.new.keys idstats.old.keys | sort | uniq > keys.tmp
|
||||
|
||||
cat keys.tmp | grep -Eo '[0-9]{13}' > ids
|
||||
|
||||
rm idstats.new
|
||||
rm idstats.new.keys
|
||||
rm idstats.old
|
||||
rm idstats.old.keys
|
||||
rm keys.tmp
|
|
@ -56,7 +56,7 @@ test('Adds new subjects, multiple new questions', () => {
|
|||
test("New subject names shouldn't be empty", () => {
|
||||
const data: RecievedData = JSON.parse(
|
||||
fs.readFileSync(
|
||||
__dirname + '/../../devel/tests/testData/ROS.json',
|
||||
__dirname + '/../../testingTools/tests/testData/ROS.json',
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
@ -80,7 +80,7 @@ test("New subject names shouldn't be empty", () => {
|
|||
test('New questions shouldnt be added to accidental empty named subjects', () => {
|
||||
const data: RecievedData = JSON.parse(
|
||||
fs.readFileSync(
|
||||
__dirname + '/../../devel/tests/testData/ROS.json',
|
||||
__dirname + '/../../testingTools/tests/testData/ROS.json',
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
@ -103,7 +103,7 @@ test('New questions shouldnt be added to accidental empty named subjects', () =>
|
|||
test('Question gets added to the correct subject', () => {
|
||||
const data: RecievedData = JSON.parse(
|
||||
fs.readFileSync(
|
||||
__dirname + '/../../devel/tests/testData/ROS.json',
|
||||
__dirname + '/../../testingTools/tests/testData/ROS.json',
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue