2016-12-28 23:49:51 +01:00
|
|
|
import * as express from 'express';
|
|
|
|
import * as request from 'request';
|
2017-01-02 22:03:19 +01:00
|
|
|
import xml2json = require('xml2json');
|
2016-12-28 23:49:51 +01:00
|
|
|
|
|
|
|
module.exports = (req: express.Request, res: express.Response) => {
|
|
|
|
const url: string = req.body.url;
|
|
|
|
|
|
|
|
request(url, (err, response, xml) => {
|
|
|
|
if (err) {
|
2017-01-07 12:37:12 +01:00
|
|
|
res.sendStatus(500);
|
|
|
|
} else {
|
|
|
|
res.send(xml2json.toJson(xml));
|
2016-12-28 23:49:51 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|