mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
express: Move static handlers to expressPreSession
This avoids the need to exempt the paths from authentication checks, and it eliminates unnecessary express-session state.
This commit is contained in:
parent
72f4ae444d
commit
649fbdccf5
10 changed files with 65 additions and 85 deletions
|
@ -28,14 +28,14 @@ const getTar = async () => {
|
|||
return tar;
|
||||
};
|
||||
|
||||
exports.expressCreateServer = async (hookName, args) => {
|
||||
exports.expressPreSession = async (hookName, {app}) => {
|
||||
// Cache both minified and static.
|
||||
const assetCache = new CachingMiddleware();
|
||||
args.app.all(/\/javascripts\/(.*)/, assetCache.handle.bind(assetCache));
|
||||
app.all(/\/javascripts\/(.*)/, assetCache.handle.bind(assetCache));
|
||||
|
||||
// Minify will serve static files compressed (minify enabled). It also has
|
||||
// file-specific hacks for ace/require-kernel/etc.
|
||||
args.app.all('/static/:filename(*)', minify.minify);
|
||||
app.all('/static/:filename(*)', minify.minify);
|
||||
|
||||
// Setup middleware that will package JavaScript files served by minify for
|
||||
// CommonJS loader on the client-side.
|
||||
|
@ -53,12 +53,12 @@ exports.expressCreateServer = async (hookName, args) => {
|
|||
const associator = new StaticAssociator(associations);
|
||||
jsServer.setAssociator(associator);
|
||||
|
||||
args.app.use(jsServer.handle.bind(jsServer));
|
||||
app.use(jsServer.handle.bind(jsServer));
|
||||
|
||||
// serve plugin definitions
|
||||
// not very static, but served here so that client can do
|
||||
// require("pluginfw/static/js/plugin-definitions.js");
|
||||
args.app.get('/pluginfw/plugin-definitions.json', (req, res, next) => {
|
||||
app.get('/pluginfw/plugin-definitions.json', (req, res, next) => {
|
||||
const clientParts = plugins.parts.filter((part) => part.client_hooks != null);
|
||||
const clientPlugins = {};
|
||||
for (const name of new Set(clientParts.map((part) => part.plugin))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue