aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/server/middleware')
-rw-r--r--vnext/server/middleware/oembed.js31
1 files changed, 2 insertions, 29 deletions
diff --git a/vnext/server/middleware/oembed.js b/vnext/server/middleware/oembed.js
index ad23d9e2..43bed194 100644
--- a/vnext/server/middleware/oembed.js
+++ b/vnext/server/middleware/oembed.js
@@ -1,39 +1,12 @@
import { embeddedTweet } from '../../src/api';
-import Cors from 'cors';
-// Initializing the cors middleware
-// You can read more about the available options here: https://github.com/expressjs/cors#configuration-options
-const cors = Cors({
- methods: ['POST', 'GET', 'HEAD'],
-});
-
-/**
- * Helper method to wait for a middleware to execute before continuing
- * And to throw an error when an error happens in a middleware
- *
- * @param {import("next").NextApiRequest} req
- * @param {import("next").NextApiResponse} res
- * @param { Function } fn
- */
-function runMiddleware(req, res, fn) {
- return new Promise((resolve, reject) => {
- fn(req, res, (result) => {
- if (result instanceof Error) {
- return reject(result);
- }
- return resolve(result);
- });
- });
-}
/**
- * Return content for embedding.
+ * Return content for embedding
*
- * @param {import("next").NextApiRequest} req
- * @param {import("next").NextApiResponse} res
+ * @type {import('express').RequestParamHandler}
*/
const oembed = async (req, res) => {
let url = (req.query.url || '').toString();
- await runMiddleware(req, res, cors);
return embeddedTweet(url).then(result => {
res.send(result);
res.end();