mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-07-01 15:49:59 +09:00
3.0.1
This commit is contained in:
22
built/server/index.js
Normal file
22
built/server/index.js
Normal 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);
|
Reference in New Issue
Block a user