mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-04-29 02:37:27 +09:00
23 lines
528 B
JavaScript
23 lines
528 B
JavaScript
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);
|