Cleanup relay server

This commit is contained in:
Timothy Farrell 2018-06-23 07:14:37 -05:00
parent 7864e4753a
commit ec1a07dffa

View File

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