diff --git a/index.ts b/index.ts index 74b28ad..6cb10de 100644 --- a/index.ts +++ b/index.ts @@ -5,16 +5,22 @@ import * as xml2js from "xml2js"; const app = new Koa(); app.use(async (ctx) => { - const { data } = await Axios.get( - "https://podcast.midline.pl/api/v1/channels/Midline/rss" - ); - const builder = new xml2js.Builder(); - const parsed_data = await xml2js.parseStringPromise(data); - parsed_data.rss.channel[0]["itunes:owner"][0]["itunes:email"] = - "kontakt@mildline.pl"; + try { + const { data } = await Axios.get( + "https://podcast.midline.pl/api/v1/channels/Midline/rss" + ); + const builder = new xml2js.Builder(); + const parsed_data = await xml2js.parseStringPromise(data); + parsed_data.rss.channel[0]["itunes:owner"][0]["itunes:email"] = + "kontakt@mildline.pl"; - ctx.body = builder.buildObject(parsed_data); - ctx.type = "application/rss+xml"; + ctx.body = builder.buildObject(parsed_data); + ctx.type = "application/rss+xml"; + } catch (e) { + console.error(e); + ctx.body = "error"; + ctx.status = 500; + } }); app.listen(3000);