Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/custom-environment-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private:
obs_user: 'OBS_USER'
obs_pass: 'OBS_PASS'
opencollective_token: 'OPENCOLLECTIVE_TOKEN'
outagedeck_api_key: 'OUTAGEDECK_API_KEY'
pepy_key: 'PEPY_KEY'
postgres_url: 'POSTGRES_URL'
readthedocs_token: 'READTHEDOCS_TOKEN'
Expand Down
1 change: 1 addition & 0 deletions config/local-shields-io-production.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ private:
gh_client_id: ...
gh_client_secret: ...
gitlab_token: ...
outagedeck_api_key: ...
readthedocs_token: ...
reddit_client_id: ...
reddit_client_secret: ...
Expand Down
1 change: 1 addition & 0 deletions core/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const privateConfigSchema = Joi.object({
obs_user: Joi.string(),
obs_pass: Joi.string(),
opencollective_token: Joi.string(),
outagedeck_api_key: Joi.string(),
pepy_key: Joi.string(),
postgres_url: Joi.string().uri({ scheme: 'postgresql' }),
readthedocs_token: Joi.string(),
Expand Down
6 changes: 6 additions & 0 deletions doc/server-secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ While OBS supports [API tokens](https://openbuildservice.org/help/manuals/obs-us

OpenCollective's GraphQL API only allows 10 reqs/minute for anonymous users. An [API token](https://graphql-docs-v2.opencollective.com/access) can be provided to access a higher rate limit of 100 reqs/minute.

### OutageDeck

- `OUTAGEDECK_API_KEY` (yml: `private.outagedeck_api_key`)

An optional Bearer key raises the OutageDeck API rate limit. The hosted Shields.io service can use its complimentary dedicated key; self-hosted instances can leave this unset and use anonymous access, which is limited to 120 requests per IP address per hour.

### Pepy

- `PEPY_KEY` (yml: `private.pepy_key`)
Expand Down
87 changes: 87 additions & 0 deletions services/outagedeck/outagedeck-status.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import Joi from 'joi'
import { BaseJsonService, pathParam } from '../index.js'

const statusSchema = Joi.string().valid(
'operational',
'degraded',
'partial_outage',
'major_outage',
'maintenance',
'unknown',
)

const schema = Joi.object({
data: Joi.object({
currentStatus: Joi.object({
code: statusSchema.required(),
}).required(),
}).required(),
}).required()

const statusColors = {
operational: 'brightgreen',
degraded: 'yellow',
partial_outage: 'orange',
major_outage: 'red',
maintenance: 'blue',
unknown: 'lightgrey',
}

export default class OutageDeckStatus extends BaseJsonService {
static category = 'monitoring'

static route = {
base: 'outagedeck/status',
pattern: ':provider',
}

static auth = {
passKey: 'outagedeck_api_key',
authorizedOrigins: ['https://outagedeck.com'],
isRequired: false,
}

static openApi = {
'/outagedeck/status/{provider}': {
get: {
summary: 'OutageDeck provider status',
description:
'Current provider status from the [OutageDeck public API](https://outagedeck.com/developers/api?utm_source=shields&utm_medium=service&utm_campaign=shields_provider_status).',
parameters: [
pathParam({
name: 'provider',
example: 'github',
description: 'The OutageDeck provider slug',
}),
],
},
},
}

static _cacheLength = 600

static defaultBadgeData = {
label: 'status',
}

static render({ status }) {
return {
message: status.replaceAll('_', ' '),
color: statusColors[status],
}
}

async fetch({ provider }) {
return this._requestJson(
this.authHelper.withBearerAuthHeader({
schema,
url: `https://outagedeck.com/api/v1/providers/${encodeURIComponent(provider)}`,
}),
)
}

async handle({ provider }) {
const response = await this.fetch({ provider })
return this.constructor.render({ status: response.data.currentStatus.code })
}
}
33 changes: 33 additions & 0 deletions services/outagedeck/outagedeck-status.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect } from 'chai'
import nock from 'nock'
import { cleanUpNockAfterEach, defaultContext } from '../test-helpers.js'
import OutageDeckStatus from './outagedeck-status.service.js'

describe('OutageDeckStatus', function () {
describe('auth', function () {
cleanUpNockAfterEach()

const config = {
private: {
outagedeck_api_key: 'fake-key',
},
}

it('sends the auth information as configured', async function () {
const scope = nock('https://outagedeck.com')
.get('/api/v1/providers/github')
.matchHeader('Authorization', 'Bearer fake-key')
.reply(200, {
data: { currentStatus: { code: 'operational' } },
})

expect(
await OutageDeckStatus.invoke(defaultContext, config, {
provider: 'github',
}),
).to.not.have.property('isError')

scope.done()
})
})
})
57 changes: 57 additions & 0 deletions services/outagedeck/outagedeck-status.tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import Joi from 'joi'
import { createServiceTester } from '../tester.js'

export const t = await createServiceTester()

const isOutageDeckStatus = Joi.string().valid(
'operational',
'degraded',
'partial outage',
'major outage',
'maintenance',
'unknown',
)

const statusCases = [
['operational', 'operational', 'brightgreen'],
['degraded', 'degraded', 'yellow'],
['partial_outage', 'partial outage', 'orange'],
['major_outage', 'major outage', 'red'],
['maintenance', 'maintenance', 'blue'],
['unknown', 'unknown', 'lightgrey'],
]

for (const [status, message, color] of statusCases) {
const provider = `example-${status}`
t.create(`OutageDeck ${status} status (mock)`)
.get(`/${provider}.json`)
.intercept(nock =>
nock('https://outagedeck.com')
.get(`/api/v1/providers/${provider}`)
.reply(200, {
meta: { version: 'v1', generatedAt: '2026-08-05T00:00:00Z' },
data: { currentStatus: { code: status } },
}),
)
.expectBadge({ label: 'status', message, color })
}

t.create('OutageDeck provider status (live)').get('/github.json').expectBadge({
label: 'status',
message: isOutageDeckStatus,
})

t.create('OutageDeck provider not found')
Comment thread
koko3tallah marked this conversation as resolved.
.get('/not-a-provider.json')
.expectBadge({ label: 'status', message: 'not found' })

t.create('OutageDeck invalid response')
.get('/invalid-response.json')
.intercept(nock =>
nock('https://outagedeck.com')
.get('/api/v1/providers/invalid-response')
.reply(200, {
data: { currentStatus: { code: 'unexpected' } },
}),
)
.expectBadge({ label: 'status', message: 'invalid response data' })
Loading