aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/oembed.js
blob: 4ac2d337ea3d14c3dfc8e348cf104f148241b21e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { embeddedTweet } from '../../src/api';

/**
 * Return content for embedding
 *
 * @type {import('express').RequestParamHandler}
 */
const oembed = async (req, res) => {
    let url = (req.query.url || '').toString();
    return embeddedTweet(url).then(result => {
        res.send(result);
        res.end();
    }).catch(err => {
        console.log(`HTTP ${err.response ? err.response.status : err.code}: ${url}`);
        res.sendStatus(err.response ? err.response.status : 500);
        res.end();
    });
};

export default oembed;