Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@hapi/code": "9.0.3",
"@hapi/lab": "26.0.0",
"proxyquire": "2.1.3",
"sinon": "21.0.0",
"standard": "17.1.2"
},
"standard": {
Expand Down
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This is the FWIS management tool
| PORT | Port number | no | 3000 | | |
| FWS_API_URL | API url | yes | | | |
| FWS_API_KEY | API key | yes | | | |
| FWS_APP_PROXY | Proxy | no | | | |
| AD_CLIENT_ID | AD Client Id | yes | | | |
| AD_CLIENT_SECRET | AD Client Secret | yes | | | |
| AD_TENANT | AD Tenant | yes | | | |
Expand Down
2 changes: 0 additions & 2 deletions server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const schema = Joi.object({
env: Joi.string().valid('dev', 'tst', 'pre', 'prd', 'tra').default('dev'),
api: Joi.string().uri().required(),
apiKey: Joi.string().required(),
proxy: Joi.string().uri().allow(''),
adClientId: Joi.string().required(),
adClientSecret: Joi.string().required(),
adTenant: Joi.string().required(),
Expand All @@ -28,7 +27,6 @@ const config = {
env: process.env.FWS_ENV_NAME,
api: process.env.FWS_API_URL,
apiKey: process.env.FWS_API_KEY,
proxy: process.env.FWS_APP_PROXY,
adClientId: process.env.AD_CLIENT_ID,
adClientSecret: process.env.AD_CLIENT_SECRET,
adTenant: process.env.AD_TENANT,
Expand Down
18 changes: 4 additions & 14 deletions server/http.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
const config = require('./config')
const { HttpsProxyAgent } = require('https-proxy-agent')

// Timeout is high to accomodate the use of lambda backend functions
const timeout = 30 * 1000

const wreck = require('@hapi/wreck').defaults({
timeout
})
let wreckExt
if (config.proxy) {
wreckExt = require('@hapi/wreck').defaults({
timeout,
agent: new HttpsProxyAgent(config.proxy)
})
}

module.exports = {
getJson: function (url, ext = false) {
const thisWreck = (ext && wreckExt) ? wreckExt : wreck
return thisWreck
getJson: function (url) {
return wreck
.get(url, {
json: true,
headers: {
Expand All @@ -32,9 +23,8 @@ module.exports = {
return response.payload
})
},
postJson: function (url, payload, ext = false) {
const thisWreck = (ext && wreckExt) ? wreckExt : wreck
return thisWreck
postJson: function (url, payload) {
return wreck
.post(url, {
json: true,
payload,
Expand Down
Loading