Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.use(express.urlencoded({extended: false}))
// View engine setup
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'twig')
app.set('twig options', {
autoescape: true
})
// Application code:
app.use(
express.static(path.join(__dirname, 'public'), {
immutable: true,
maxAge: '1h'
})
)
Twig.extendFilter('sanitizeHtml', sanitizeHtmlTwigFilter)
app.get('/', (req, res, _next) => {
res.redirect('/login')
})
app.use('/login', loginRouter)
app.use('/', inboxRouter)
// Catch 404 and forward to error handler
app.use((req, res, next) => {
next({message: 'page not found', status: 404})
})
// Error handler
app.use((err, req, res, _next) => {
// Set locals, only providing error in development
'use strict';
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
const ansiStyles = require('ansi-styles');
const Twig = require('twig');
// Add Chalk to Twig
for (const style of Object.keys(ansiStyles)) {
Twig.extendFilter(style, input => chalk[style](input));
}
exports.get = (message, data) => {
const fileTemplate = fs.readFileSync(path.join(__dirname, 'messages', `${message}.twig`), 'utf8');
return Twig.twig({data: fileTemplate}).render(data);
};
const moment = require('moment');
require('twig')
.extendFilter('noscript', value => {
if (!value) return value;
return value.replace(/\//gi, '\\/');
});
module.exports = {
starts_with(string, path) {
var pattern = new RegExp('^' + string.replace('/', '\\/'));
return pattern.test(path);
}
};
*/
twig.extendFunction('svg', function (path) {
return fs.readFileSync(__dirname + '/..' + path, 'utf-8');
});
/**
* Function for getting full named event-type
*
* @usage {{ event.tag | event-type }}
*
* @param eventTag - 'fatal', 'warnings', 'notice' or 'javascript' type of error
*
* @returns {String} - full named event-type
*/
twig.extendFilter('event-type', function (eventTag) {
switch (eventTag) {
case 'fatal':
return 'Fatal Error';
case 'warnings':
return 'Warning';
case 'notice':
return 'Notice';
case 'javascript':
return 'JavaScript Error';
}
});
}();
options.filters.forEach(function (filter) {
Twig.extendFilter(filter.name, filter.func);
});
}
Object.keys(this.options.filters).forEach(function(name) {
var fn = this.options.filters[name];
if (!isFunction(fn)) {
grunt.fail.fatal('"' + name + '" needs to be a function!');
}
Twig.extendFilter(name, fn);
}.bind(this));
Object.entries(query.filters).forEach(([name, fn]) => Twig.extendFilter(name, fn));
}