summaryrefslogtreecommitdiff
path: root/lib/response.js
diff options
context:
space:
mode:
authorDavid Mehren2021-02-16 20:15:15 +0100
committerGitHub2021-02-16 20:15:15 +0100
commit59819be34c2428450528362a5bbb74b6424d15d2 (patch)
treead80595f5dd94a7ac63bc1481943ae7b356ddb17 /lib/response.js
parent6b8fa94402539168a5bd574ddcc17eeae4910bd0 (diff)
parent136d895d155f28c2e75b3af206549acaa2a354ed (diff)
Merge pull request #872 from hedgedoc/renovate/master-major-linters
Diffstat (limited to 'lib/response.js')
-rw-r--r--lib/response.js56
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/response.js b/lib/response.js
index a56273a2..10ecd035 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -1,28 +1,28 @@
'use strict'
// response
// external modules
-var fs = require('fs')
-var path = require('path')
-var request = require('request')
+const fs = require('fs')
+const path = require('path')
+const request = require('request')
// core
-var config = require('./config')
-var logger = require('./logger')
-var models = require('./models')
+const config = require('./config')
+const logger = require('./logger')
+const models = require('./models')
const noteUtil = require('./web/note/util')
const errors = require('./errors')
// public
-var response = {
+const response = {
showIndex: showIndex,
githubActions: githubActions,
gitlabActions: gitlabActions
}
function showIndex (req, res, next) {
- var authStatus = req.isAuthenticated()
- var deleteToken = ''
+ const authStatus = req.isAuthenticated()
+ const deleteToken = ''
- var data = {
+ const data = {
signin: authStatus,
infoMessage: req.flash('info'),
errorMessage: req.flash('error'),
@@ -49,9 +49,9 @@ function showIndex (req, res, next) {
}
function githubActions (req, res, next) {
- var noteId = req.params.noteId
+ const noteId = req.params.noteId
noteUtil.findNote(req, res, function (note) {
- var action = req.params.action
+ const action = req.params.action
switch (action) {
case 'gist':
githubActionGist(req, res, note)
@@ -64,41 +64,41 @@ function githubActions (req, res, next) {
}
function githubActionGist (req, res, note) {
- var code = req.query.code
- var state = req.query.state
+ const code = req.query.code
+ const state = req.query.state
if (!code || !state) {
return errors.errorForbidden(res)
} else {
- var data = {
+ const data = {
client_id: config.github.clientID,
client_secret: config.github.clientSecret,
code: code,
state: state
}
- var authUrl = 'https://github.com/login/oauth/access_token'
+ const authUrl = 'https://github.com/login/oauth/access_token'
request({
url: authUrl,
method: 'POST',
json: data
}, function (error, httpResponse, body) {
if (!error && httpResponse.statusCode === 200) {
- var accessToken = body.access_token
+ const accessToken = body.access_token
if (accessToken) {
- var content = note.content
- var title = models.Note.decodeTitle(note.title)
- var filename = title.replace('/', ' ') + '.md'
- var gist = {
- 'files': {}
+ const content = note.content
+ const title = models.Note.decodeTitle(note.title)
+ const filename = title.replace('/', ' ') + '.md'
+ const gist = {
+ files: {}
}
gist.files[filename] = {
- 'content': content
+ content: content
}
- var gistUrl = 'https://api.github.com/gists'
+ const gistUrl = 'https://api.github.com/gists'
request({
url: gistUrl,
headers: {
'User-Agent': 'HedgeDoc',
- 'Authorization': 'token ' + accessToken
+ Authorization: 'token ' + accessToken
},
method: 'POST',
json: gist
@@ -121,9 +121,9 @@ function githubActionGist (req, res, note) {
}
function gitlabActions (req, res, next) {
- var noteId = req.params.noteId
+ const noteId = req.params.noteId
noteUtil.findNote(req, res, function (note) {
- var action = req.params.action
+ const action = req.params.action
switch (action) {
case 'projects':
gitlabActionProjects(req, res, note)
@@ -143,7 +143,7 @@ function gitlabActionProjects (req, res, note) {
}
}).then(function (user) {
if (!user) { return errors.errorNotFound(res) }
- var ret = { baseURL: config.gitlab.baseURL, version: config.gitlab.version }
+ const ret = { baseURL: config.gitlab.baseURL, version: config.gitlab.version }
ret.accesstoken = user.accessToken
ret.profileid = user.profileid
request(