mirror of
https://github.com/PretendoNetwork/juxtaposition-ui.git
synced 2026-03-22 01:44:08 -05:00
34 lines
842 B
JavaScript
34 lines
842 B
JavaScript
const util = require('../util');
|
|
|
|
async function staticFiles(request, response, next) {
|
|
// Web files
|
|
if (isStartOfPath(request.path, '/css/') ||
|
|
isStartOfPath(request.path, '/fonts/') ||
|
|
isStartOfPath(request.path, '/js/') ||
|
|
request.path === '/favicon.ico' ||
|
|
isStartOfPath(request.path, '/web/') ||
|
|
isStartOfPath(request.path, '/images/') ||
|
|
isStartOfPath(request.path, '/image/')) {
|
|
|
|
response.locals.lang = util.processLanguage();
|
|
|
|
if (request.subdomains.includes('juxt')) {
|
|
request.directory = 'web';
|
|
} else {
|
|
request.directory = request.subdomains[1];
|
|
}
|
|
return next();
|
|
} else if (request.path === '/') {
|
|
return response.redirect('/titles/show');
|
|
} else {
|
|
return response.sendStatus(404);
|
|
}
|
|
}
|
|
|
|
function isStartOfPath(path, value) {
|
|
return path.indexOf(value) === 0;
|
|
}
|
|
|
|
|
|
module.exports = staticFiles;
|