Introduce processor
This commit is contained in:
parent
68ce6d5748
commit
90f8fe7e53
582 changed files with 246 additions and 188 deletions
15
src/server/web/service/url-preview.ts
Normal file
15
src/server/web/service/url-preview.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import * as express from 'express';
|
||||
import summaly from 'summaly';
|
||||
|
||||
module.exports = async (req: express.Request, res: express.Response) => {
|
||||
const summary = await summaly(req.query.url);
|
||||
summary.icon = wrap(summary.icon);
|
||||
summary.thumbnail = wrap(summary.thumbnail);
|
||||
res.send(summary);
|
||||
};
|
||||
|
||||
function wrap(url: string): string {
|
||||
return url != null
|
||||
? `https://images.weserv.nl/?url=${url.replace(/^https?:\/\//, '')}`
|
||||
: null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue