chore: code formatting
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
//Imports
|
||||
import octokit from "@octokit/graphql"
|
||||
import OctokitRest from "@octokit/rest"
|
||||
import axios from "axios"
|
||||
import compression from "compression"
|
||||
import crypto from "crypto"
|
||||
import express from "express"
|
||||
import ratelimit from "express-rate-limit"
|
||||
import cache from "memory-cache"
|
||||
import util from "util"
|
||||
import url from "url"
|
||||
import axios from "axios"
|
||||
import util from "util"
|
||||
import mocks from "../../../tests/mocks/index.mjs"
|
||||
import metrics from "../metrics/index.mjs"
|
||||
import presets from "../metrics/presets.mjs"
|
||||
import setup from "../metrics/setup.mjs"
|
||||
import crypto from "crypto"
|
||||
|
||||
/**App */
|
||||
export default async function({sandbox = false} = {}) {
|
||||
@@ -68,8 +68,9 @@ export default async function({sandbox = false} = {}) {
|
||||
console.debug(`metrics/app/session/${login} > authenticated with session ${session.substring(0, 6)}, using custom octokit`)
|
||||
return {login, graphql: octokit.graphql.defaults({headers: {authorization: `token ${token}`}}), rest: new OctokitRest.Octokit({auth: token})}
|
||||
}
|
||||
else if (session)
|
||||
else if (session) {
|
||||
console.debug(`metrics/app/session > unknown session ${session.substring(0, 6)}, using default octokit`)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -238,11 +239,14 @@ export default async function({sandbox = false} = {}) {
|
||||
try {
|
||||
//Authorize user
|
||||
console.debug("metrics/app/oauth > authorization")
|
||||
const {data} = await axios.post("https://github.com/login/oauth/access_token", `${new url.URLSearchParams({
|
||||
const {data} = await axios.post(
|
||||
"https://github.com/login/oauth/access_token",
|
||||
`${new url.URLSearchParams({
|
||||
client_id: conf.settings.oauth.id,
|
||||
client_secret: conf.settings.oauth.secret,
|
||||
code,
|
||||
})}`)
|
||||
})}`,
|
||||
)
|
||||
const token = new url.URLSearchParams(data).get("access_token")
|
||||
//Validate user
|
||||
const {data: {login}} = await axios.get("https://api.github.com/user", {headers: {Authorization: `token ${token}`}})
|
||||
@@ -279,8 +283,9 @@ export default async function({sandbox = false} = {}) {
|
||||
app.get("/.oauth/redirect", limiter, (req, res) => res.sendFile(`${conf.paths.statics}/oauth/redirect.html`))
|
||||
app.get("/.oauth/enabled", limiter, (req, res) => res.json(true))
|
||||
}
|
||||
else
|
||||
else {
|
||||
app.get("/.oauth/enabled", limiter, (req, res) => res.json(false))
|
||||
}
|
||||
|
||||
//Pending requests
|
||||
const pending = new Map()
|
||||
|
||||
@@ -352,7 +352,7 @@
|
||||
if (!Array.isArray(this.extras))
|
||||
return this.extras
|
||||
return required.filter(permission => !this.extras.includes(permission)).length === 0
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user