diff --git a/server/github.js b/server/github.js index d2335fbb..5c93ff55 100644 --- a/server/github.js +++ b/server/github.js @@ -1,21 +1,21 @@ -var qs = require('qs'); -var request = require('request'); +const qs = require('qs'); // eslint-disable-line import/no-extraneous-dependencies +const request = require('request'); function githubToken(clientId, code) { - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { request({ method: 'POST', url: 'https://github.com/login/oauth/access_token', qs: { client_id: clientId, client_secret: process.env.GITHUB_SECRET, - code: code + code, }, - }, function(err, res, body) { + }, (err, res, body) => { if (err) { reject(err); } - var token = qs.parse(body).access_token; + const token = qs.parse(body).access_token; if (token) { resolve(token); } else { @@ -25,11 +25,9 @@ function githubToken(clientId, code) { }); } -exports.githubToken = function (req, res) { +exports.githubToken = (req, res) => { githubToken(req.query.clientId, req.query.code) - .then(function (token) { - res.send(token); - }, function (err) { - res.status(400).send(err ? err.message || err.toString() : 'bad_code'); - }); + .then( + token => res.send(token), + err => res.status(400).send(err ? err.message || err.toString() : 'bad_code')); }; diff --git a/server/index.js b/server/index.js index 1c867908..cefc618f 100644 --- a/server/index.js +++ b/server/index.js @@ -15,7 +15,7 @@ module.exports = (app, serveV4) => { // Enable CORS for fonts if (/\.(eot|ttf|woff|svg)$/.test(req.url)) { res.header('Access-Control-Allow-Origin', '*'); - }; + } next(); }); @@ -33,9 +33,7 @@ module.exports = (app, serveV4) => { } // Serve callback.html in /app - app.get('/oauth2/callback', function(req, res) { - res.sendFile(path.join(__dirname, '../static/oauth2/callback.html')); - }); + app.get('/oauth2/callback', (req, res) => res.sendFile(path.join(__dirname, '../static/oauth2/callback.html'))); // Serve static resources if (process.env.NODE_ENV === 'production') {