New project structure
Beta of extract.js for extracting english locale
This commit is contained in:
parent
e18d2b2f84
commit
2edbd67205
247 changed files with 6405 additions and 4237 deletions
35
server/routes/index.js
Normal file
35
server/routes/index.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
const passport = require('../lib/passport');
|
||||
const _ = require('../lib/translate')._;
|
||||
const clientHelpers = require('../lib/client-helpers');
|
||||
const { getTrustedUrl } = require('../lib/urls');
|
||||
const { AppType } = require('../../shared/app');
|
||||
|
||||
const routerFactory = require('../lib/router-async');
|
||||
|
||||
function getRouter(appType) {
|
||||
const router = routerFactory.create();
|
||||
|
||||
if (appType === AppType.TRUSTED) {
|
||||
router.getAsync('/*', passport.csrfProtection, async (req, res) => {
|
||||
const mailtrainConfig = await clientHelpers.getAnonymousConfig(req.context, appType);
|
||||
if (req.user) {
|
||||
Object.assign(mailtrainConfig, await clientHelpers.getAuthenticatedConfig(req.context));
|
||||
}
|
||||
|
||||
res.render('root', {
|
||||
reactCsrfToken: req.csrfToken(),
|
||||
mailtrainConfig: JSON.stringify(mailtrainConfig),
|
||||
scriptFiles: [
|
||||
getTrustedUrl('mailtrain/root.js')
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
|
||||
module.exports.getRouter = getRouter;
|
Loading…
Add table
Add a link
Reference in a new issue