blurts-server/routes/email-l10n.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 строки
1.0 KiB
JavaScript
Исходник Обычный вид История

'use strict'
const express = require('express')
const helmet = require('helmet')
2022-09-15 09:19:08 +03:00
const { getEmailMockup, sendTestEmail, notFound } = require('../controllers/email-l10n')
const { requireAdminUser } = require('../middleware')
const csrf = require('csurf')
const csrfProtection = csrf()
const router = express.Router()
const cspUnsafeInline = {
directives: {
2022-09-15 09:19:08 +03:00
defaultSrc: ["'self'"],
scriptSrc: ["'self'"],
styleSrc: ["'self'", "'unsafe-inline'"],
imgSrc: ["'self'", 'https://monitor.cdn.mozilla.net/'],
objectSrc: ["'none'"],
2022-09-15 09:19:08 +03:00
formAction: ["'self'"]
}
}
2022-09-15 09:19:08 +03:00
// Route needs unsafe-inline because inline styles are required as best-practice for HTML email styling.
// Route requires admin user and is not enabled for production.
router.get('/', requireAdminUser, csrfProtection, helmet.contentSecurityPolicy(cspUnsafeInline), getEmailMockup)
router.post('/send-test-email', express.urlencoded({ extended: false }), csrfProtection, requireAdminUser, sendTestEmail)
2018-11-03 00:21:08 +03:00
router.use(notFound)
module.exports = router