summaryrefslogtreecommitdiff
path: root/src/web/service/url-preview.ts
blob: d1a345ef17c03bb7de654f4a316955b5d1886af0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 `${config.proxy_url}/${url}`;
}