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