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

Commit

Permalink
Made final tweaks to code pre 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Donald Robertson committed May 1, 2017
1 parent 8ed1f79 commit 4d3c0b9
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 30 deletions.
11 changes: 1 addition & 10 deletions lib/request/compile-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,4 @@ const _ = require('lodash')
const hyperid = require('hyperid')
const instance = hyperid()

// module.exports = (body) => {
// if (body.includes('<%=') && body.includes('%>')) {
// const compileBody = _.template(body)
// return compileBody({ hyperid: instance() })
// }
//
// return body
// }

module.exports = (body) => _.template(body)({ hyperid: instance() })
module.exports = (body) => _.template(body)({ unique_id: instance() })
6 changes: 0 additions & 6 deletions lib/request/compile-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,4 @@ module.exports = (headers, variables) => {
return _.mapValues(headers, compileHeader(variables))
}

// const compileHeader = (variables) => (value) => {
// return value.includes('<%=') && value.includes('%>')
// ? _.template(value)(variables)
// : value
// }

const compileHeader = (variables) => (value) => _.template(value)(variables)
6 changes: 0 additions & 6 deletions lib/request/compile-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@

const _ = require('lodash')

// module.exports = (url, variables) => {
// return url.includes('<%=') && url.includes('%>')
// ? _.template(url)(variables)
// : url
// }

module.exports = (url, variables) => _.template(url)(variables)
2 changes: 1 addition & 1 deletion test/contracts/consumer-valid-broken-after-hook.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Content-Type": "application/json"
},
"body": {
"email": "<%= hyperid %>@test.com"
"email": "<%= unique_id %>@test.com"
}
},
"response": {
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/consumer-valid-broken-before-hook.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Content-Type": "application/json"
},
"body": {
"email": "<%= hyperid %>@test.com"
"email": "<%= unique_id %>@test.com"
}
},
"response": {
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/consumer-valid-broken-before-hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Content-Type": "application/json"
},
"body": {
"email": "<%= hyperid %>@test.com"
"email": "<%= unique_id %>@test.com"
}
},
"response": {
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/consumer-valid-passing-after-hook.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Content-Type": "application/json"
},
"body": {
"email": "<%= hyperid %>@test.com"
"email": "<%= unique_id %>@test.com"
}
},
"response": {
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/consumer-valid-passing-before-hook.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Content-Type": "application/json"
},
"body": {
"email": "<%= hyperid %>@test.com"
"email": "<%= unique_id %>@test.com"
}
},
"response": {
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/consumer-valid-passing-before-hooks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Content-Type": "application/json"
},
"body": {
"email": "<%= hyperid %>@test.com"
"email": "<%= unique_id %>@test.com"
}
},
"response": {
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/consumer-valid-passing-unique-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Content-Type": "application/json"
},
"body": {
"email": "<%= hyperid %>@test.com"
"email": "<%= unique_id %>@test.com"
}
},
"response": {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Provider.prototype.start = function (options, done) {
})

app.post('/api/user', (req, res) => {
if (req.body.email.startsWith('<%= hyperid %>')) {
if (req.body.email.startsWith('<%= unique_id %>')) {
res.status(400).send({ message: 'Email Address In Use' })
} else {
res.status(201).send({ id: 1, email: req.body.email })
Expand Down

0 comments on commit 4d3c0b9

Please sign in to comment.