aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/oembed.js
blob: ea53ca9cc0871f0ee27762b8d54a29f99076fc33 (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(`Err: ${err.response ? err.response.status : err.code}`);
        res.sendStatus(err.response ? err.response.status : 500);
        res.end();
    });
};

export default oembed;