mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
feat: some env vars support
This commit is contained in:
parent
afc58503b7
commit
9d4c08e460
@ -22,7 +22,7 @@ const self = {
|
||||
onHold: new Set()
|
||||
}
|
||||
|
||||
const homeDomain = config.homeDomain || config.domain
|
||||
const homeDomain = utils.conf.homeDomain || utils.conf.domain
|
||||
|
||||
const zipMaxTotalSize = parseInt(config.cloudflare.zipMaxTotalSize)
|
||||
const zipMaxTotalSizeBytes = zipMaxTotalSize * 1e6
|
||||
@ -447,14 +447,14 @@ self.get = async (req, res, next) => {
|
||||
|
||||
for (const file of files) {
|
||||
if (req._upstreamCompat) {
|
||||
file.url = `${config.domain}/${file.name}`
|
||||
file.url = `${utils.conf.domain}/${file.name}`
|
||||
} else {
|
||||
file.file = `${config.domain}/${file.name}`
|
||||
file.file = `${utils.conf.domain}/${file.name}`
|
||||
}
|
||||
|
||||
const extname = utils.extname(file.name)
|
||||
if (utils.mayGenerateThumb(extname)) {
|
||||
file.thumb = `${config.domain}/thumbs/${file.name.slice(0, -extname.length)}.png`
|
||||
file.thumb = `${utils.conf.domain}/thumbs/${file.name.slice(0, -extname.length)}.png`
|
||||
if (req._upstreamCompat) file.thumbSquare = file.thumb
|
||||
}
|
||||
}
|
||||
|
@ -938,7 +938,7 @@ self.sendUploadResponse = async (req, res, user, result) => {
|
||||
files: result.map(file => {
|
||||
const map = {
|
||||
name: file.name,
|
||||
url: `${config.domain ? `${config.domain}/` : ''}${file.name}`
|
||||
url: `${utils.conf.domain ? `${utils.conf.domain}/` : ''}${file.name}`
|
||||
}
|
||||
|
||||
// If a temporary upload, add expiry date
|
||||
@ -1021,7 +1021,7 @@ self.list = async (req, res, next) => {
|
||||
const ismoderator = perms.is(user, 'moderator')
|
||||
if (all && !ismoderator) return res.status(403).end()
|
||||
|
||||
const basedomain = config.domain
|
||||
const basedomain = utils.conf.domain
|
||||
|
||||
// Thresholds for regular users
|
||||
const MAX_WILDCARDS_IN_KEY = 2
|
||||
|
@ -16,6 +16,12 @@ const logger = require('./../logger')
|
||||
|
||||
const self = {
|
||||
db: knex(config.database),
|
||||
conf: {
|
||||
// Allow some config options to be overriden via env vars
|
||||
port: process.env.PORT || config.port,
|
||||
domain: process.env.DOMAIN || config.domain,
|
||||
homeDomain: process.env.HOME_DOMAIN || config.homeDomain
|
||||
},
|
||||
scan: {
|
||||
instance: null,
|
||||
version: null,
|
||||
@ -632,8 +638,8 @@ self.purgeCloudflareCache = async (names, uploads, thumbs) => {
|
||||
return [{ success: false, files: [], errors }]
|
||||
}
|
||||
|
||||
let domain = config.domain
|
||||
if (!uploads) domain = config.homeDomain
|
||||
let domain = self.conf.domain
|
||||
if (!uploads) domain = self.conf.homeDomain
|
||||
|
||||
const thumbNames = []
|
||||
names = names.map(name => {
|
||||
|
@ -343,8 +343,8 @@ safe.use('/api', api)
|
||||
}
|
||||
|
||||
// Binds Express to port
|
||||
await new Promise(resolve => safe.listen(config.port, () => resolve()))
|
||||
logger.log(`lolisafe started on port ${config.port}`)
|
||||
await new Promise(resolve => safe.listen(utils.conf.port, () => resolve()))
|
||||
logger.log(`lolisafe started on port ${utils.conf.port}`)
|
||||
|
||||
// Cache control (safe.fiery.me)
|
||||
// Purge Cloudflare cache
|
||||
|
Loading…
Reference in New Issue
Block a user