Moved public dirs to seperate directories

This commit is contained in:
MrFry 2020-04-13 11:37:29 +02:00
parent 3b25be8a60
commit a2e1996298
9 changed files with 108 additions and 44 deletions

View file

@ -18,6 +18,7 @@
------------------------------------------------------------------------- */
// package requires
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
@ -25,36 +26,44 @@ const uuidv4 = require('uuid/v4') // TODO: deprecated, but imports are not suppo
const fs = require('fs')
const app = express()
// const http = require('http')
// const https = require('https')
// other requires
const logger = require('../../utils/logger.js')
const utils = require('../../utils/utils.js')
const actions = require('../../utils/actions.js')
const dbtools = require('../../utils/dbtools.js')
const auth = require('../../middlewares/auth.middleware.js')
const recivedFiles = 'public/recivedfiles'
const uloadFiles = 'public/f'
const dataFile = 'public/data.json'
// files
const msgFile = 'stats/msgs'
const motdFile = 'public/motd'
const versionFile = 'public/version'
const passwordFile = 'data/dataEditorPasswords.json'
const dataEditsLog = 'stats/dataEdits'
const dailyDataCountFile = 'stats/dailyDataCount'
const usersDbBackupPath = 'data/dbs/backup'
// other constants
const maxVeteranPwGetCount = 10
const addPWPerDay = 1 // every x day a user can give a pw
const maxPWCount = 6 // maximum pw give opportunities a user can have at once
const daysAfterUserGetsPWs = 2 // days after user gets pw-s
// stuff gotten from server.js
let userDB
let url
let url // eslint-disable-line
let publicdirs = []
function GetApp () {
const p = publicdirs[0]
if (!p) {
throw new Error(`No public dir! ( API )`)
}
// files in public dirs
const recivedFiles = p + 'recivedfiles'
const uloadFiles = p + 'f'
const dataFile = p + 'data.json'
const motdFile = p + 'motd'
const versionFile = p + 'version'
app.use(bodyParser.urlencoded({
limit: '10mb',
extended: true

View file

@ -18,17 +18,21 @@
------------------------------------------------------------------------- */
// package requires
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const app = express()
// other requires
const utils = require('../../utils/utils.js')
const logger = require('../../utils/logger.js')
const auth = require('../../middlewares/auth.middleware.js')
// stuff gotten from server.js
let userDB
let publicdirs = []
let nextdir = ''
function GetApp () {
app.use(bodyParser.urlencoded({
@ -55,6 +59,7 @@ function GetApp () {
logger.Log(`Using public dir: ${pdir}`)
app.use(express.static(pdir))
})
app.use(express.static(nextdir))
app.use(busboy({
limits: {
fileSize: 10000 * 1024 * 1024
@ -80,7 +85,7 @@ function GetApp () {
})
})
}
AddHtmlRoutes(utils.ReadDir('modules/dataEditor/public'))
AddHtmlRoutes(utils.ReadDir(nextdir))
// --------------------------------------------------------------
@ -107,4 +112,5 @@ exports.getApp = GetApp
exports.setup = (data) => {
userDB = data.userDB
publicdirs = data.publicdirs
nextdir = data.nextdir
}

View file

@ -18,18 +18,18 @@
------------------------------------------------------------------------- */
let url = '' // http(s)//asd.basd
// package requires
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const app = express()
// other requires
const logger = require('../../utils/logger.js')
// const utils = require('../utils/utils.js')
// const actions = require('../utils/actions.js')
// stuff gotten from server.js
let publicdirs = []
let url = '' // http(s)//asd.basd
function GetApp () {
app.set('view engine', 'ejs')

View file

@ -18,18 +18,22 @@
------------------------------------------------------------------------- */
// package requires
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const app = express()
// other requires
const utils = require('../../utils/utils.js')
const logger = require('../../utils/logger.js')
const auth = require('../../middlewares/auth.middleware.js')
// stuff gotten from server.js
let donateURL = ''
let publicdirs = []
let userDB
let nextdir = ''
try {
donateURL = utils.ReadFile('./data/donateURL')
@ -66,6 +70,7 @@ function GetApp () {
logger.Log(`Using public dir: ${pdir}`)
app.use(express.static(pdir))
})
app.use(express.static(nextdir))
app.use(busboy({
limits: {
fileSize: 10000 * 1024 * 1024
@ -171,7 +176,7 @@ function GetApp () {
})
})
}
AddHtmlRoutes(utils.ReadDir('modules/qmining/public'))
AddHtmlRoutes(utils.ReadDir(nextdir))
// --------------------------------------------------------------
@ -205,4 +210,5 @@ exports.getApp = GetApp
exports.setup = (data) => {
userDB = data.userDB
publicdirs = data.publicdirs
nextdir = data.nextdir
}

View file

@ -18,22 +18,29 @@
------------------------------------------------------------------------- */
// package requires
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const fs = require('fs')
const app = express()
// const http = require('http')
// const https = require('https')
// other requires
const logger = require('../../utils/logger.js')
const utils = require('../../utils/utils.js')
const uloadFiles = './public/f'
// stuff gotten from server.js
let publicdirs = []
function GetApp () {
const p = publicdirs[0]
if (!p) {
throw new Error(`No public dir! ( SIO )`)
}
// files in public dirs
const uloadFiles = p + 'f'
app.set('view engine', 'ejs')
app.set('views', [
'./modules/sio/views',

View file

@ -18,22 +18,29 @@
------------------------------------------------------------------------- */
// package requires
const express = require('express')
const bodyParser = require('body-parser')
const busboy = require('connect-busboy')
const fs = require('fs')
const app = express()
// other requires
const logger = require('../../utils/logger.js')
// stuff gotten from server.js
let publicdirs = []
let url = ''
const logger = require('../../utils/logger.js')
// const utils = require('../utils/utils.js')
// const actions = require('../utils/actions.js')
const listedFiles = './public/files'
let publicdirs = []
function GetApp () {
const p = publicdirs[0]
if (!p) {
throw new Error(`No public dir! ( Stuff )`)
}
// files in public dirs
const listedFiles = p + 'files'
app.set('view engine', 'ejs')
app.set('views', [
'./modules/stuff/views',