mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
removed some domain dependencies
This commit is contained in:
parent
f8a7c6a4e5
commit
bc45b11551
13 changed files with 17 additions and 31 deletions
|
@ -24,7 +24,6 @@ import type { Database } from 'better-sqlite3'
|
|||
|
||||
import logger from '../utils/logger'
|
||||
import dbtools from '../utils/dbtools'
|
||||
import constants from '../constants'
|
||||
|
||||
interface Options {
|
||||
userDB: Database
|
||||
|
@ -51,9 +50,7 @@ function renderLogin(req: Request, res: Response) {
|
|||
msg: 'You are not logged in',
|
||||
})
|
||||
} else {
|
||||
res.render('login', {
|
||||
domain: constants.domain,
|
||||
})
|
||||
res.render('login')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ function setupSubModules(
|
|||
const loadedModData = mod.setup({
|
||||
app: parentApp,
|
||||
userDB: userDB,
|
||||
url: url,
|
||||
url: url, // only used by userManagement.ts
|
||||
publicdirs: publicdirs,
|
||||
moduleSpecificData: moduleSpecificData,
|
||||
httpServer: httpServer,
|
||||
|
|
|
@ -26,7 +26,7 @@ import { Request, SubmoduleData } from '../../../types/basicTypes'
|
|||
const uloadFiles = 'data/f'
|
||||
|
||||
function setup(data: SubmoduleData): void {
|
||||
const { app /* userDB, url, publicdirs, moduleSpecificData */ } = data
|
||||
const { app } = data
|
||||
|
||||
app.route('/fosuploader').post(function (req: Request, res: Response) {
|
||||
utils.uploadFile(req, uloadFiles).then(({ fileName }) => {
|
||||
|
|
|
@ -184,8 +184,7 @@ function getPostData(
|
|||
}
|
||||
|
||||
function setup(data: SubmoduleData): void {
|
||||
const { app, /* userDB, url, */ publicdirs /*, moduleSpecificData */ } =
|
||||
data
|
||||
const { app, publicdirs } = data
|
||||
|
||||
const publicDir = publicdirs[0]
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ function setup(data: SubmoduleData): Submodule {
|
|||
const {
|
||||
app,
|
||||
userDB,
|
||||
/* url */ publicdirs,
|
||||
publicdirs,
|
||||
moduleSpecificData: { getQuestionDbs, setQuestionDbs, dbsFile },
|
||||
} = data
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ interface QuickVote {
|
|||
}
|
||||
|
||||
function setup(data: SubmoduleData): void {
|
||||
const { app /* userDB, url, publicdirs, moduleSpecificData */ } = data
|
||||
const { app } = data
|
||||
|
||||
app.get('/quickvote', (req: Request, res: Response) => {
|
||||
const key = req.query.key.toString()
|
||||
|
|
|
@ -58,7 +58,7 @@ function mergeObjSum(a: Subjects, b: Subjects) {
|
|||
}
|
||||
|
||||
function setup(data: SubmoduleData): void {
|
||||
const { app /* userDB, url, publicdirs, moduleSpecificData */ } = data
|
||||
const { app } = data
|
||||
|
||||
app.get('/ranklist', (req: Request, res) => {
|
||||
logger.LogReq(req)
|
||||
|
|
|
@ -74,7 +74,7 @@ interface Todos {
|
|||
const todosFile = 'data/todos.json'
|
||||
|
||||
function setup(data: SubmoduleData): void {
|
||||
const { app /* userDB, url, publicdirs, moduleSpecificData */ } = data
|
||||
const { app } = data
|
||||
|
||||
app.get('/voteTodo', (req: Request, res: Response) => {
|
||||
logger.LogReq(req)
|
||||
|
|
|
@ -83,7 +83,7 @@ function listDir(publicDir: string, subdir: string, userFilesDir: string) {
|
|||
}
|
||||
|
||||
function setup(data: SubmoduleData): void {
|
||||
const { app, /* userDB, url, */ publicdirs /* moduleSpecificData */ } = data
|
||||
const { app, publicdirs } = data
|
||||
|
||||
app.use((req: Request, _res, next) => {
|
||||
// /userFiles/test/2021-04-28_10-59.png
|
||||
|
|
|
@ -90,7 +90,7 @@ function createDefaultUser(userDb: Database) {
|
|||
const validationTokenName = 'qmining' // readValidationTokenName()
|
||||
|
||||
function setup(data: SubmoduleData): Submodule {
|
||||
const { app, userDB, url /* publicdirs, moduleSpecificData */ } = data
|
||||
const { app, userDB, url } = data
|
||||
const domain: any = url
|
||||
logger.DebugLog(`Cookie domain: ${domain}`, 'cookie', 1)
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import { LinksSchema, validateJSON } from '../../types/typeSchemas'
|
|||
let publicdirs: string[] = []
|
||||
let userDB: Database
|
||||
let nextdir = ''
|
||||
let domain = ''
|
||||
|
||||
function GetApp(): ModuleType {
|
||||
app.use(
|
||||
|
@ -112,18 +111,10 @@ function GetApp(): ModuleType {
|
|||
// REDIRECTS
|
||||
// --------------------------------------------------------------
|
||||
|
||||
// to be backwards compatible
|
||||
app.get('/ask', function (req: Request, res) {
|
||||
logger.DebugLog(`Qmining module ask redirect`, 'ask', 1)
|
||||
res.redirect(
|
||||
`http://${domain}/ask?q=${req.query.q}&subj=${req.query.subj}&data=${req.query.data}`
|
||||
)
|
||||
})
|
||||
|
||||
const simpleRedirects = [
|
||||
{
|
||||
from: '/install',
|
||||
to: `https://${domain}/moodle-test-userscript/stable.user.js`,
|
||||
to: `/moodle-test-userscript/stable.user.js`,
|
||||
},
|
||||
{
|
||||
from: '/servergit',
|
||||
|
@ -163,15 +154,15 @@ function GetApp(): ModuleType {
|
|||
},
|
||||
{
|
||||
from: '/allqr',
|
||||
to: `https://${domain}/api/allqr.txt`,
|
||||
to: `/api/allqr.txt`,
|
||||
},
|
||||
{
|
||||
from: '/allqr.txt',
|
||||
to: `https://${domain}/api/allqr.txt`,
|
||||
to: `/api/allqr.txt`,
|
||||
},
|
||||
{
|
||||
from: '/infos',
|
||||
to: `https://${domain}/api/infos?version=true&motd=true&subjinfo=true`,
|
||||
to: `/api/infos?version=true&motd=true&subjinfo=true`,
|
||||
nolog: true,
|
||||
},
|
||||
{
|
||||
|
@ -261,7 +252,6 @@ export default {
|
|||
name: 'Qmining',
|
||||
getApp: GetApp,
|
||||
setup: (data: SetupData): void => {
|
||||
domain = data.url
|
||||
userDB = data.userDB
|
||||
publicdirs = data.publicdirs
|
||||
nextdir = data.nextdir
|
||||
|
|
|
@ -239,7 +239,7 @@ Object.keys(modules).forEach(function (key) {
|
|||
|
||||
if (mod.setup) {
|
||||
mod.setup({
|
||||
url: constants.domain,
|
||||
url: constants.domain, // used by api.ts -> userManagement.ts -> cookies
|
||||
userDB: userDB,
|
||||
publicdirs: module.publicdirs,
|
||||
nextdir: module.nextdir,
|
||||
|
@ -267,7 +267,7 @@ app.get('*', (req, res) => {
|
|||
if (req.is('application/json')) {
|
||||
res.status(404).end()
|
||||
} else {
|
||||
res.status(404).render('404', { domain: constants.domain })
|
||||
res.status(404).render('404')
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<body bgcolor="#222426">
|
||||
<head>
|
||||
<title>Qmining | <%= domain %> - Login</title>
|
||||
<title>Qmining - Login</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.6" />
|
||||
<style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue