From 5a3411586939de7189601c19a526e6e70f33f773 Mon Sep 17 00:00:00 2001 From: mrfry Date: Mon, 1 May 2023 09:17:13 +0200 Subject: [PATCH] public dir fixes --- src/modules/api/submodules/userManagement.ts | 8 ++++---- src/server.ts | 2 -- src/types/basicTypes.ts | 1 - src/types/typeSchemas.ts | 7 +------ 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/modules/api/submodules/userManagement.ts b/src/modules/api/submodules/userManagement.ts index 0f561e7..b64ca2e 100644 --- a/src/modules/api/submodules/userManagement.ts +++ b/src/modules/api/submodules/userManagement.ts @@ -31,6 +31,7 @@ import { } from '../../../types/basicTypes' import dbtools from '../../../utils/dbtools' import { queueWork } from '../../../worker/workerPool' +import constants from '../../../constants' const minimumAlowwedSessions = 2 // how many sessions are allowed for a user const usersDbBackupPath = 'data/dbs/backup' @@ -91,9 +92,8 @@ function createDefaultUser(userDb: Database) { const validationTokenName = 'qmining' // readValidationTokenName() function setup(data: SubmoduleData): Submodule { - const { app, userDB, url } = data - const domain: any = url - logger.DebugLog(`Cookie domain: ${domain}`, 'cookie', 1) + const { app, userDB } = data + logger.DebugLog(`Cookie domain: ${constants.domain}`, 'cookie', 1) const userCount = dbtools .TableInfo(userDB, 'users') @@ -245,7 +245,7 @@ function setup(data: SubmoduleData): Submodule { // https://www.npmjs.com/package/cookie res.cookie('sessionID', sessionID, { - domain: domain, + domain: constants.domain, expires: new Date( new Date().getTime() + 10 * 365 * 24 * 60 * 60 * 1000 ), diff --git a/src/server.ts b/src/server.ts index 09e06be..328edba 100755 --- a/src/server.ts +++ b/src/server.ts @@ -42,7 +42,6 @@ import dbtools from './utils/dbtools' import reqlogger from './middlewares/reqlogger.middleware' import idStats from './utils/ids' import { paths, validateAndSetupFiles } from './utils/files' -import constants from './constants' const logFile = paths.logDir + logger.logFileName const vlogFile = paths.vlogDir + logger.logFileName @@ -233,7 +232,6 @@ Object.keys(modules).forEach(function (key) { if (mod.setup) { mod.setup({ - url: constants.domain, // used by api.ts -> userManagement.ts -> cookies userDB: userDB, nextdir: module.nextdir, httpServer: httpServer, diff --git a/src/types/basicTypes.ts b/src/types/basicTypes.ts index 3861fca..8ed1cdb 100644 --- a/src/types/basicTypes.ts +++ b/src/types/basicTypes.ts @@ -121,7 +121,6 @@ export interface ModuleSpecificData { export interface SubmoduleData { app: express.Application - url: string userDB?: Database nextdir?: string moduleSpecificData: ModuleSpecificData diff --git a/src/types/typeSchemas.ts b/src/types/typeSchemas.ts index 375167a..497f2aa 100644 --- a/src/types/typeSchemas.ts +++ b/src/types/typeSchemas.ts @@ -139,17 +139,12 @@ export const ModuleSchema: Schema = { type: 'object', properties: { path: { type: 'string' }, - publicdirs: { - type: 'array', - minItems: 1, // FIXME: make this a single string, no need for array - items: { type: 'string' }, - }, nextDir: { type: 'string' }, name: { type: 'string' }, route: { type: 'string' }, isNextJs: { type: 'boolean' }, }, - required: ['path', 'publicdirs', 'name', 'route'], + required: ['path', 'name', 'route'], } export const ModulesSchema: Schema = {