|
@@ -9,16 +9,19 @@ function stripEvents(str) {
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
- index: function(req, res) {
|
|
|
|
- res.send(stripEvents(routes().toString('/', state(req))));
|
|
|
|
|
|
+ index: async function(req, res) {
|
|
|
|
+ const appState = await state(req);
|
|
|
|
+ res.send(stripEvents(routes().toString('/', appState)));
|
|
},
|
|
},
|
|
|
|
|
|
- blank: function(req, res) {
|
|
|
|
- res.send(stripEvents(routes().toString('/blank', state(req))));
|
|
|
|
|
|
+ blank: async function(req, res) {
|
|
|
|
+ const appState = await state(req);
|
|
|
|
+ res.send(stripEvents(routes().toString('/blank', appState)));
|
|
},
|
|
},
|
|
|
|
|
|
download: async function(req, res, next) {
|
|
download: async function(req, res, next) {
|
|
const id = req.params.id;
|
|
const id = req.params.id;
|
|
|
|
+ const appState = await state(req);
|
|
try {
|
|
try {
|
|
const { nonce, pwd } = await storage.metadata(id);
|
|
const { nonce, pwd } = await storage.metadata(id);
|
|
res.set('WWW-Authenticate', `send-v1 ${nonce}`);
|
|
res.set('WWW-Authenticate', `send-v1 ${nonce}`);
|
|
@@ -26,7 +29,7 @@ module.exports = {
|
|
stripEvents(
|
|
stripEvents(
|
|
routes().toString(
|
|
routes().toString(
|
|
`/download/${id}`,
|
|
`/download/${id}`,
|
|
- Object.assign(state(req), {
|
|
|
|
|
|
+ Object.assign(appState, {
|
|
downloadMetadata: { nonce, pwd }
|
|
downloadMetadata: { nonce, pwd }
|
|
})
|
|
})
|
|
)
|
|
)
|
|
@@ -37,22 +40,25 @@ module.exports = {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- unsupported: function(req, res) {
|
|
|
|
|
|
+ unsupported: async function(req, res) {
|
|
|
|
+ const appState = await state(req);
|
|
res.send(
|
|
res.send(
|
|
stripEvents(
|
|
stripEvents(
|
|
routes().toString(
|
|
routes().toString(
|
|
`/unsupported/${req.params.reason}`,
|
|
`/unsupported/${req.params.reason}`,
|
|
- Object.assign(state(req), { fira: true })
|
|
|
|
|
|
+ Object.assign(appState, { fira: true })
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
);
|
|
},
|
|
},
|
|
|
|
|
|
- legal: function(req, res) {
|
|
|
|
- res.send(stripEvents(routes().toString('/legal', state(req))));
|
|
|
|
|
|
+ legal: async function(req, res) {
|
|
|
|
+ const appState = await state(req);
|
|
|
|
+ res.send(stripEvents(routes().toString('/legal', appState)));
|
|
},
|
|
},
|
|
|
|
|
|
- notfound: function(req, res) {
|
|
|
|
- res.status(404).send(stripEvents(routes().toString('/404', state(req))));
|
|
|
|
|
|
+ notfound: async function(req, res) {
|
|
|
|
+ const appState = await state(req);
|
|
|
|
+ res.status(404).send(stripEvents(routes().toString('/404', appState)));
|
|
}
|
|
}
|
|
};
|
|
};
|