diff --git a/endpoints/appveyor.ts b/endpoints/appveyor.ts new file mode 100644 index 0000000..7831626 --- /dev/null +++ b/endpoints/appveyor.ts @@ -0,0 +1,33 @@ +import got from '../libs/got' +import { + badgenServe, + BadgenServeMeta as Meta, + BadgenServeHandlers as Handlers, + BadgenServeHandlerArgs as Args +} from '../libs/badgen-serve' + +export const meta: Meta = { + title: 'AppVeyor', + examples: { + '/appveyor/ci/gruntjs/grunt': 'build', + '/appveyor/ci/gruntjs/grunt/deprecate': 'build (branch)' + } +} + +export const handlers: Handlers = { + '/appveyor/ci/:account/:project/:branch?': handler +} + +async function handler ({ account, project, branch }: Args) { + branch = branch ? `/branch/${branch}` : '' + const endpoint = `https://ci.appveyor.com/api/projects/${account}/${project}${branch}` + const { build } = await got(endpoint).then(res => res.body) + + return { + subject: 'appveyor', + status: build.status, + color: build.status === 'success' ? 'green' : 'red' + } +} + +export default badgenServe(handlers) diff --git a/libs/examples.ts b/libs/examples.ts index 5a56e87..c990d90 100644 --- a/libs/examples.ts +++ b/libs/examples.ts @@ -6,6 +6,7 @@ const rel = (...args) => path.resolve(__dirname, ...args) // sort live badge examples manually const liveBadgeExampleList = [ 'github', + 'appveyor', 'amo', 'apm', 'homebrew'