Skip to content
Permalink
Browse files

refactor: Use external cors implementation

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
  • Loading branch information
Richienb committed Mar 18, 2020
1 parent 64480c9 commit e64cbf6a3db82425b371f9fcb8341412a2257c9d
Showing with 15 additions and 11 deletions.
  1. +0 −8 middleware/cors.js
  2. +1 −0 package.json
  3. +3 −0 routes/post.js
  4. +1 −1 server.js
  5. +10 −2 yarn.lock

This file was deleted.

@@ -28,6 +28,7 @@
"@sindresorhus/is": "^2.0.0",
"any-size": "^1.0.0",
"btoa": "^1.2.1",
"cors": "^2.8.5",
"ejs": "^3.0.1",
"escape-goat": "^3.0.0",
"express": "^4.17.1",
@@ -17,15 +17,18 @@ const { validDomainId } = require('./utils')
function getUserData ({ query, body }) {
// If query parameters provided
if (size(query) > 0) return query

// If the data parsed as {'{data: "value"}': ''}
if (size(body) === 1 && !Object.values(body)[0]) return JSON.parse(Object.keys(body)[0])

// Fallback
return body
}

// HTTP POST API
module.exports = async (req, res) => {
const { hostname } = req

// Get different parts of hostname (example: remy.mit-license.org -> ['remy', 'mit-license', 'org'])
const params = hostname.split('.')

@@ -48,7 +48,7 @@ app.use(
// Middleware

// CORS
app.use(require('./middleware/cors'))
app.use(require('cors'))
// Parse URL-encoded bodies (as sent by HTML forms)
app.use(
express.urlencoded({
@@ -711,6 +711,14 @@ core-util-is@~1.0.0:
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=

cors@^2.8.5:
version "2.8.5"
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
dependencies:
object-assign "^4"
vary "^1"

cosmiconfig@^2.1.0, cosmiconfig@^2.1.1:
version "2.2.2"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-2.2.2.tgz#6173cebd56fac042c1f4390edf7af6c07c7cb892"
@@ -2636,7 +2644,7 @@ num2fraction@^1.2.2:
resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede"
integrity sha1-b2gragJ6Tp3fpFZM0lidHU5mnt4=

object-assign@4.X, object-assign@^4.0.0, object-assign@^4.1.0, object-assign@^4.1.1:
object-assign@4.X, object-assign@^4, object-assign@^4.0.0, object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
@@ -4299,7 +4307,7 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

vary@~1.1.2:
vary@^1, vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=

0 comments on commit e64cbf6

Please sign in to comment.
You can’t perform that action at this time.