'use strict'
const serverSecrets = require('../../lib/server-secrets')
const { colorScale } = require('../../lib/color-formatters')
const {
checkErrorResponse: standardCheckErrorResponse,
} = require('../../lib/error-helper')
const documentation = `
If your GitHub badge errors, it might be because you hit GitHub's rate limits.
You can increase Shields.io's rate limit by
going to this page to add
Shields as a GitHub application on your GitHub account.
`
function stateColor(s) {
return { open: '2cbe4e', closed: 'cb2431', merged: '6f42c1' }[s]
}
function errorMessagesFor(notFoundMessage = 'repo not found') {
return {
404: notFoundMessage,
422: notFoundMessage,
}
}
function checkErrorResponse(
badgeData,
err,
res,
notFoundMessage = 'repo not found',
errorMessages = {}
) {
return standardCheckErrorResponse(badgeData, err, res, {
...errorMessages,
...errorMessagesFor(notFoundMessage),
})
}
const commentsColor = colorScale([1, 3, 10, 25], undefined, true)
function staticAuthConfigured() {
return Boolean(serverSecrets.gh_token)
}
module.exports = {
documentation,
stateColor,
commentsColor,
errorMessagesFor,
checkErrorResponse,
staticAuthConfigured,
}