const express = require('express');
const cors = require('cors');
const router = express.Router();

router.get('/', cors(), function(req, res, next) {
  const incomingUrl = req.query.url;
  const embedUrl = incomingUrl+'?minimal';
  const width = req.query.maxwidth || 700;
  const height = req.query.maxheight || 500;
  const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl;
  if (incomingUrl) {
    res.send({
      status: 200,
      headers: {
        'Content-Type': 'application/json'
      },
      body: {
        type: 'rich',
        version: '1.0',
        provider_name: 'npmcharts',
        provider_url: "https://npmcharts.com",
        width: width,
        height: height,
        html: `<!DOCTYPE html>
          <html>
              <head>
                  <meta charset="UTF-8">
                  <style>
                  html, body { padding: 0; margin: 0; }
                  </style>
              </head>
              <body>
                  <iframe
                      style="width: 100%; overflow: hidden;"
                      src="${embedUrl}"
                      width="500"
                      height="${height}"
                      frameborder="0"
                      scrolling="no"
                  ></iframe>
              </body>
          </html>
          `
      }
    });
  } else {
    res
      .status(400)
      .send({
        message: 'Please pass a url on the query string',
      });
  }
});

module.exports = router;


@@ -428,110 +428,8 @@
 d(%7B%0A
-      status: 200,%0A      headers: %7B%0A        'Content-Type': 'application/json'%0A      %7D,%0A      body: %7B%0A
     
@@ -1223,16 +1223,8 @@
   %60%0A
-      %7D%0A
     

fix oembed format, remove unnecessary fields