Use ETag middleware

This commit is contained in:
D. Berge
2023-09-01 12:28:55 +02:00
parent e8b1cb27f1
commit 308eda6342

View File

@@ -83,6 +83,9 @@ app.map({
app.use(mw.auth.authentify); app.use(mw.auth.authentify);
// Don't process the request if the data hasn't changed
app.use(mw.etag.ifNoneMatch);
// We must be authenticated before we can access these // We must be authenticated before we can access these
app.map({ app.map({
'/project': { '/project': {
@@ -274,12 +277,12 @@ app.map({
}, },
'/queue/outgoing/': { '/queue/outgoing/': {
'asaqc': { 'asaqc': {
get: [ mw.queue.asaqc.get ], get: [ mw.etag.noSave, mw.queue.asaqc.get ],
post: [ mw.auth.access.write, mw.queue.asaqc.post ], post: [ mw.auth.access.write, mw.queue.asaqc.post ],
'/project/:project': { '/project/:project': {
get: [ mw.queue.asaqc.get ], get: [ mw.etag.noSave, mw.queue.asaqc.get ],
'/sequence/:sequence': { '/sequence/:sequence': {
get: [ mw.queue.asaqc.get ], get: [ mw.etag.noSave, mw.queue.asaqc.get ],
} }
}, },
'/:id': { '/:id': {
@@ -303,6 +306,10 @@ app.map({
// //
}); });
app.use(mw.etag.save);
// Invalidate cache on database events
mw.etag.watch(app);
// Generic error handler. Stops stack dumps // Generic error handler. Stops stack dumps
// being sent to clients. // being sent to clients.
app.use(function (err, req, res, next) { app.use(function (err, req, res, next) {