UNPKG

475 BJavaScriptView Raw
1module.exports = ({
2 Embedly,
3 router,
4 authMiddleware,
5 asyncMiddleware,
6 getConfig,
7 handleResponse,
8 handleError,
9}) => {
10
11 router.get(
12 '/embedly/oembed.:ext?',
13 authMiddleware,
14 asyncMiddleware(async (req, res) => {
15 const embedly = Embedly(await getConfig());
16
17 try {
18 handleResponse(req, res, await embedly.oembed(req.query.url || req.query.urls));
19 } catch (error) {
20 handleError(req, res, error);
21 }
22 })
23 );
24};