Merge pull request #85 from tycrek/fixed-custom-index-loading

pull/87/head
Josh Moore 3 years ago committed by GitHub
commit d3ef432eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -66,10 +66,11 @@ useSsl && app.use(helmet.hsts({ preload: true })); // skipcq: JS-0093
app.use(nofavicon);
// Use custom index, otherwise render README.md
const ASS_INDEX = indexFile !== '' && fs.existsSync(`./${indexFile}`) && (typeof require(`./${indexFile}`) === typeof Function);
app.get('/', (req, res, next) => ASS_INDEX // skipcq: JS-0229
const ASS_INDEX = indexFile !== '' && fs.existsSync(`./${indexFile}`) && require(`./${indexFile}`);
const ASS_INDEX_ENABLED = typeof ASS_INDEX === typeof Function;
app.get('/', (req, res, next) => ASS_INDEX_ENABLED // skipcq: JS-0229
? ASS_INDEX(req, res, next)
: fs.readFile(path('README.md'))
: fs.readFile(path('.github', 'README.md'))
.then((bytes) => bytes.toString())
.then(marked)
.then((d) => res.render('index', { data: d }))
@ -94,6 +95,6 @@ log
.info('Files', `${data.size}`)
.info('Data engine', data.name, data.type)
.info('Frontend', ASS_FRONTEND.enabled ? ASS_FRONTEND.brand : 'disabled', `${ASS_FRONTEND.enabled ? `${getTrueHttp()}${getTrueDomain()}${ASS_FRONTEND.endpoint}` : ''}`)
.info('Custom index', ASS_INDEX ? `enabled` : 'disabled')
.info('Custom index', ASS_INDEX_ENABLED ? `enabled` : 'disabled')
.blank()
.express().Host(app, port, host, () => log.success('Ready for uploads', `Storing resources ${s3enabled ? 'in S3' : 'on disk'}`));

Loading…
Cancel
Save