Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Update decodeURI stuff for GET and add launch.json.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Ling committed Apr 2, 2018
1 parent f9ffa75 commit 1db731d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\app.js"
}
]
}
4 changes: 3 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ if (!process.env.WHITELIST) {
app.use(cors(corsOptions))
}

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
extended: true
}))

app.post('/:appName', mWare.addHeaders, mWare.getResponse)

Expand Down
6 changes: 3 additions & 3 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ addHeaders = function(req, res, next) {
req.container.headers[`${process.env[variable + '_KEY']}`] = process.env[`${variable}_VALUE`]
}

req.apiUrl = process.env[`${req.params.appName}_URL`] || req.body.apiUrl || false
req.apiUrl = process.env[`${req.params.appName}_URL`] || decodeURI(JSON.parse(req.body.apiUrl)) || false

if (req.container.headers['']) {
res.json({
Expand Down Expand Up @@ -54,7 +54,7 @@ addHeaders = function(req, res, next) {
}

getResponse = function(req, res, next) {
console.log(req.container.headers, req.body)
//console.log(req.apiUrl)
let reqConfig = {
url: req.apiUrl,
headers: req.container.headers,
Expand All @@ -79,4 +79,4 @@ getResponse = function(req, res, next) {
module.exports = middleware = {
addHeaders,
getResponse
}
}

0 comments on commit 1db731d

Please sign in to comment.