mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
global public dir for every server module
This commit is contained in:
parent
eed99e6f02
commit
0381f6ddab
18 changed files with 55 additions and 225 deletions
|
@ -39,7 +39,7 @@ import {
|
|||
Submodule,
|
||||
} from '../../types/basicTypes'
|
||||
import { loadJSON } from '../../utils/actions'
|
||||
import { paths } from '../../utils/files'
|
||||
import { paths, publicDir } from '../../utils/files'
|
||||
import { initWorkerPool } from '../../worker/workerPool'
|
||||
|
||||
// other paths
|
||||
|
@ -48,18 +48,12 @@ const moduleName = 'API'
|
|||
// stuff gotten from server.js
|
||||
let userDB: Database
|
||||
let url: string
|
||||
let publicdirs: string[] = []
|
||||
let httpServer: http.Server
|
||||
let httpsServer: https.Server
|
||||
|
||||
function GetApp(): ModuleType {
|
||||
const app = express()
|
||||
|
||||
const publicDir = publicdirs[0]
|
||||
if (!publicDir) {
|
||||
throw new Error(`No public dir! ( API )`)
|
||||
}
|
||||
|
||||
let domain: any = url.split('.')
|
||||
domain.shift()
|
||||
domain = domain.join('.') // "qmining.com"
|
||||
|
@ -157,9 +151,7 @@ function GetApp(): ModuleType {
|
|||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
publicdirs.forEach((pdir) => {
|
||||
app.use(express.static(pdir))
|
||||
})
|
||||
app.use(express.static(publicDir))
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -206,7 +198,6 @@ function setupSubModules(
|
|||
app: parentApp,
|
||||
userDB: userDB,
|
||||
url: url, // only used by userManagement.ts
|
||||
publicdirs: publicdirs,
|
||||
moduleSpecificData: moduleSpecificData,
|
||||
httpServer: httpServer,
|
||||
httpsServer: httpsServer,
|
||||
|
@ -227,7 +218,6 @@ export default {
|
|||
setup: (data: SetupData): void => {
|
||||
userDB = data.userDB
|
||||
url = data.url
|
||||
publicdirs = data.publicdirs
|
||||
httpServer = data.httpServer
|
||||
httpsServer = data.httpsServer
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue