aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/oembed.js
blob: 8b1ed61df47d5bf1ad5f12aee23a6a7d06891d4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;