aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/oembed.js
blob: 43bed194543bfab7140cc9d6818195e48c6719f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.status}`);
        res.status(err.response.status);
        res.send({});
        res.end();
    });
};

export default oembed;