26 lines
527 B
TypeScript
26 lines
527 B
TypeScript
import Koa from "koa";
|
|
import Axios from "axios";
|
|
import * as xml2js from "xml2js";
|
|
|
|
const app = new Koa();
|
|
|
|
function trim(str: string, length: number): string {
|
|
return str.length <= length ? str : str.slice(0, length - 1) + "…";
|
|
}
|
|
|
|
app.use(async (ctx) => {
|
|
try {
|
|
const { data } = await Axios.get(
|
|
"https://podcast.internet-czas-dzialac.pl/@icd/feed.xml"
|
|
);
|
|
ctx.body = data;
|
|
ctx.type = "application/rss+xml";
|
|
} catch (e) {
|
|
console.error(e);
|
|
ctx.body = "error";
|
|
ctx.status = 500;
|
|
}
|
|
});
|
|
|
|
app.listen(3000);
|