This commit is contained in:
tamaina
2023-02-12 12:20:19 +00:00
parent 7eb9cbb4a6
commit 199b247e85
30 changed files with 639 additions and 2 deletions

22
built/server/index.js Normal file
View File

@ -0,0 +1,22 @@
import * as http from 'http';
import * as Koa from 'koa';
import summaly from '../';
const app = new Koa();
app.use(async (ctx) => {
if (!ctx.query.url) {
ctx.status = 400;
return;
}
try {
const summary = await summaly(ctx.query.url, {
lang: ctx.query.lang,
followRedirects: false
});
ctx.body = summary;
}
catch (e) {
ctx.status = 500;
}
});
const server = http.createServer(app.callback());
server.listen(process.env.PORT || 80);