Cleanup relay server

This commit is contained in:
Timothy Farrell 2018-06-23 07:14:37 -05:00
parent 0881b4fec3
commit 50582089fb

View File

@ -20,12 +20,10 @@ app.use(
); );
app.get('/api/v1/authorize_account', (req, res) => { app.get('/api/v1/authorize_account', (req, res) => {
const auth = req.get('Authorization');
request( request(
{ {
url: B2_BASE_URL + 'b2_authorize_account', url: B2_BASE_URL + 'b2_authorize_account',
headers: { Authorization: auth } headers: { Authorization: req.get('Authorization') }
}, },
function(error, response, body) { function(error, response, body) {
res.set(response.headers); res.set(response.headers);
@ -34,10 +32,10 @@ app.get('/api/v1/authorize_account', (req, res) => {
); );
}); });
app.post('/api/v1/get_upload_url', (req, res) => { const POSTRedirect = url => (req, res) => {
request.post( request.post(
{ {
url: req.get('apiUrl') + '/b2api/v1/b2_get_upload_url', url: req.get('apiUrl') + url,
headers: { Authorization: req.get('Authorization') }, headers: { Authorization: req.get('Authorization') },
body: req.body body: req.body
}, },
@ -45,20 +43,10 @@ app.post('/api/v1/get_upload_url', (req, res) => {
res.send(body); res.send(body);
} }
); );
}); };
app.post('/api/v1/remove_file', (req, res) => { app.post('/api/v1/get_upload_url', POSTRedirect('/b2api/v1/b2_get_upload_url'));
request.post( app.post('/api/v1/remove_file', POSTRedirect('/b2api/v1/b2_delete_file_version'));
{
url: req.get('apiUrl') + '/b2api/v1/b2_delete_file_version',
headers: { Authorization: req.get('Authorization') },
body: req.body
},
function(error, response, body) {
res.send(body);
}
);
});
module.exports = { module.exports = {
app: app app: app