Skip to content

Instantly share code, notes, and snippets.

@Yuripetusko
Created June 22, 2018 08:47
Show Gist options
  • Save Yuripetusko/641b19dfc0edd267c585a3548a3c5800 to your computer and use it in GitHub Desktop.
Save Yuripetusko/641b19dfc0edd267c585a3548a3c5800 to your computer and use it in GitHub Desktop.
const util = require('util');
module.exports = (app, addon) => {
app.get('/', (req, res) => {
res.format({
'text/html': () => {
res.redirect('/atlassian-connect.json');
},
'application/json': () => {
res.redirect('/atlassian-connect.json');
},
});
});
app.get('/heroku-build-status', addon.authenticate(), (req, res) => {
console.log('req.query', req.query);
const { issueKey } = req.query;
const httpClient = addon.httpClient(req);
httpClient.get(`/rest/api/2/issue/${issueKey}`, (err, response, body) => {
console.log('err', err);
if (error) {
res.send(`ERROR: ${error}`);
} else {
if (body && body.fields && body.fields.customfield_10700) {
}
}
console.log('body', body);
res.render('hello-world', {
title: 'Atlassian Connect',
});
});
});
app.get('/addonData', addon.checkValidToken(), (req, res) => {
var httpClient = addon.httpClient(req);
httpClient.get(
{
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
url: '/rest/atlassian-connect/latest/addons/' + addon.key,
},
(err, response, body) => {
if (err) {
console.log(response.statusCode + ': ' + err);
res.send('Error: ' + response.statusCode + ': ' + err);
} else {
console.log(response.statusCode, body);
res.send(body);
}
}
);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment