Files
shields/services/github/github-helpers.js
chris48s 4132ca2e7e Add blog post about token pool, improve 'authorise our app' CTA (#10683)
* Add blog post about token pool, improve 'authorise our app' CTA

* simplify first sentence
2024-11-16 16:50:04 +00:00

38 lines
945 B
JavaScript

import { colorScale } from '../color-formatters.js'
import { InvalidResponse, NotFound } from '../index.js'
const documentation = `
You can help increase Shields.io's rate limit by
[authorizing the Shields.io GitHub application](https://img.shields.io/github-auth).
Read more about [how it works](/blog/token-pool).
`
function issueStateColor(s) {
return { open: '2cbe4e', closed: '6f42c1' }[s]
}
function httpErrorsFor(notFoundMessage = 'repo not found') {
return {
404: notFoundMessage,
422: notFoundMessage,
}
}
function transformErrors(errors, entity = 'repo') {
if (errors[0].type === 'NOT_FOUND') {
return new NotFound({ prettyMessage: `${entity} not found` })
} else {
return new InvalidResponse({ prettyMessage: errors[0].message })
}
}
const commentsColor = colorScale([1, 3, 10, 25], undefined, true)
export {
documentation,
issueStateColor,
commentsColor,
httpErrorsFor,
transformErrors,
}