-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from openstad/development
Development
- Loading branch information
Showing
24 changed files
with
1,757 additions
and
8,401 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,51 @@ | ||
const rp = require('request-promise'); | ||
const fetch = require('node-fetch'); | ||
const apiUrl = process.env.API_URL; | ||
const siteApiKey = process.env.SITE_API_KEY; | ||
|
||
exports.allForSite = (req, res, next) => { | ||
var options = { | ||
uri: `${apiUrl}/api/site/${req.params.siteId}/idea?includeUser=1&includeVoteCount=1&includeUserVote=1`, | ||
exports.allForSite = async(req, res, next) => { | ||
|
||
try { | ||
let response = await fetch(`${apiUrl}/api/site/${req.params.siteId}/idea?includeUser=1&includeVoteCount=1&includeUserVote=1`, { | ||
headers: { | ||
'Accept': 'application/json', | ||
"X-Authorization": siteApiKey | ||
'Accept': 'application/json', | ||
"X-Authorization": siteApiKey | ||
}, | ||
json: true // Automatically parses the JSON string in the response | ||
}; | ||
|
||
|
||
rp(options) | ||
.then(function (ideas) { | ||
req.ideas = ideas; | ||
res.locals.ideas = ideas; | ||
next(); | ||
method: 'GET', | ||
}) | ||
.catch(function (err) { | ||
next(); | ||
}); | ||
if (!response.ok) { | ||
console.log(response); | ||
throw new Error('Fetch failed') | ||
} | ||
let ideas = await response.json(); | ||
req.ideas = ideas; | ||
res.locals.ideas = ideas; | ||
return next(); | ||
} catch(err) { | ||
return next(); | ||
} | ||
|
||
} | ||
|
||
exports.oneForSite = (req, res, next) => { | ||
var options = { | ||
uri: `${apiUrl}/api/site/${req.params.siteId}/idea/${req.params.ideaId}?includeUser=1&includeVoteCount=1&includeUserVote=1`, | ||
exports.oneForSite = async(req, res, next) => { | ||
|
||
try { | ||
let response = await fetch(`${apiUrl}/api/site/${req.params.siteId}/idea/${req.params.ideaId}?includeUser=1&includeVoteCount=1&includeUserVote=1`, { | ||
headers: { | ||
'Accept': 'application/json', | ||
"X-Authorization": siteApiKey | ||
// "Authorization" : auth | ||
'Accept': 'application/json', | ||
"X-Authorization": siteApiKey | ||
}, | ||
json: true // Automatically parses the JSON string in the response | ||
}; | ||
|
||
rp(options) | ||
.then(function (idea) { | ||
req.idea = idea; | ||
res.locals.idea = idea; | ||
next(); | ||
method: 'GET', | ||
}) | ||
.catch(function (err) { | ||
next(); | ||
}); | ||
if (!response.ok) { | ||
console.log(response); | ||
throw new Error('Fetch failed') | ||
} | ||
let idea = await response.json(); | ||
req.idea = idea; | ||
res.locals.idea = idea; | ||
return next(); | ||
} catch(err) { | ||
return next(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1603865
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Published new image:
openstad/admin:master-1603865
1603865
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Published new image:
openstad/admin:development-1603865
1603865
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Published new image:
openstad/admin:release-wolkenstad-1603865