Refactor jira,jitpack,jsdelivr,keybase service files (#5581)
This commit is contained in:
@@ -21,44 +21,34 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class JiraIssue extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'issue-tracking'
|
||||
static category = 'issue-tracking'
|
||||
|
||||
static route = {
|
||||
base: 'jira/issue',
|
||||
pattern: ':issueKey',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'jira/issue',
|
||||
pattern: ':issueKey',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
static auth = authConfig
|
||||
|
||||
static get auth() {
|
||||
return authConfig
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'JIRA issue',
|
||||
namedParams: {
|
||||
issueKey: 'KAFKA-2896',
|
||||
},
|
||||
queryParams: {
|
||||
baseUrl: 'https://issues.apache.org/jira',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
issueKey: 'KAFKA-2896',
|
||||
statusName: 'Resolved',
|
||||
statusColor: 'green',
|
||||
}),
|
||||
static examples = [
|
||||
{
|
||||
title: 'JIRA issue',
|
||||
namedParams: {
|
||||
issueKey: 'KAFKA-2896',
|
||||
},
|
||||
]
|
||||
}
|
||||
queryParams: {
|
||||
baseUrl: 'https://issues.apache.org/jira',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
issueKey: 'KAFKA-2896',
|
||||
statusName: 'Resolved',
|
||||
statusColor: 'green',
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { color: 'lightgrey', label: 'jira' }
|
||||
}
|
||||
static defaultBadgeData = { color: 'lightgrey', label: 'jira' }
|
||||
|
||||
static render({ issueKey, statusName, statusColor }) {
|
||||
let color = 'lightgrey'
|
||||
|
||||
@@ -33,44 +33,34 @@ const documentation = `
|
||||
`
|
||||
|
||||
module.exports = class JiraSprint extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'issue-tracking'
|
||||
static category = 'issue-tracking'
|
||||
|
||||
static route = {
|
||||
base: 'jira/sprint',
|
||||
pattern: ':sprintId',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'jira/sprint',
|
||||
pattern: ':sprintId',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
static auth = authConfig
|
||||
|
||||
static get auth() {
|
||||
return authConfig
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'JIRA sprint completion',
|
||||
namedParams: {
|
||||
sprintId: '94',
|
||||
},
|
||||
queryParams: {
|
||||
baseUrl: 'https://jira.spring.io',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
numCompletedIssues: 27,
|
||||
numTotalIssues: 28,
|
||||
}),
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'JIRA sprint completion',
|
||||
namedParams: {
|
||||
sprintId: '94',
|
||||
},
|
||||
]
|
||||
}
|
||||
queryParams: {
|
||||
baseUrl: 'https://jira.spring.io',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
numCompletedIssues: 27,
|
||||
numTotalIssues: 28,
|
||||
}),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'jira' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'jira' }
|
||||
|
||||
static render({ numCompletedIssues, numTotalIssues }) {
|
||||
const percentComplete = numTotalIssues
|
||||
|
||||
@@ -10,35 +10,27 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class JitPackVersion extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
static category = 'version'
|
||||
|
||||
static route = {
|
||||
base: 'jitpack/v',
|
||||
pattern: ':vcs(github|bitbucket|gitlab|gitee)/:user/:repo',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'jitpack/v',
|
||||
pattern: ':vcs(github|bitbucket|gitlab|gitee)/:user/:repo',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'JitPack',
|
||||
namedParams: {
|
||||
vcs: 'github',
|
||||
user: 'jitpack',
|
||||
repo: 'maven-simple',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: 'v1.1' }),
|
||||
keywords: ['java', 'maven'],
|
||||
static examples = [
|
||||
{
|
||||
title: 'JitPack',
|
||||
namedParams: {
|
||||
vcs: 'github',
|
||||
user: 'jitpack',
|
||||
repo: 'maven-simple',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: renderVersionBadge({ version: 'v1.1' }),
|
||||
keywords: ['java', 'maven'],
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'jitpack' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'jitpack' }
|
||||
|
||||
async fetch({ vcs, user, repo }) {
|
||||
const url = `https://jitpack.io/api/builds/com.${vcs}.${user}/${repo}/latest`
|
||||
|
||||
@@ -3,26 +3,22 @@
|
||||
const { schema, periodMap, BaseJsDelivrService } = require('./jsdelivr-base')
|
||||
|
||||
module.exports = class JsDelivrHitsGitHub extends BaseJsDelivrService {
|
||||
static get route() {
|
||||
return {
|
||||
base: 'jsdelivr/gh',
|
||||
pattern: ':period(hd|hw|hm|hy)/:user/:repo',
|
||||
}
|
||||
static route = {
|
||||
base: 'jsdelivr/gh',
|
||||
pattern: ':period(hd|hw|hm|hy)/:user/:repo',
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'jsDelivr hits (GitHub)',
|
||||
namedParams: {
|
||||
period: 'hm',
|
||||
user: 'jquery',
|
||||
repo: 'jquery',
|
||||
},
|
||||
staticPreview: this.render({ period: 'hm', hits: 9809876 }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'jsDelivr hits (GitHub)',
|
||||
namedParams: {
|
||||
period: 'hm',
|
||||
user: 'jquery',
|
||||
repo: 'jquery',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ period: 'hm', hits: 9809876 }),
|
||||
},
|
||||
]
|
||||
|
||||
async fetch({ period, user, repo }) {
|
||||
return this._requestJson({
|
||||
|
||||
@@ -3,36 +3,32 @@
|
||||
const { schema, periodMap, BaseJsDelivrService } = require('./jsdelivr-base')
|
||||
|
||||
module.exports = class JsDelivrHitsNPM extends BaseJsDelivrService {
|
||||
static get route() {
|
||||
return {
|
||||
base: 'jsdelivr/npm',
|
||||
pattern: ':period(hd|hw|hm|hy)/:scope(@[^/]+)?/:packageName',
|
||||
}
|
||||
static route = {
|
||||
base: 'jsdelivr/npm',
|
||||
pattern: ':period(hd|hw|hm|hy)/:scope(@[^/]+)?/:packageName',
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'jsDelivr hits (npm)',
|
||||
pattern: ':period(hd|hw|hm|hy)/:packageName',
|
||||
namedParams: {
|
||||
period: 'hm',
|
||||
packageName: 'jquery',
|
||||
},
|
||||
staticPreview: this.render({ period: 'hm', hits: 920101789 }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'jsDelivr hits (npm)',
|
||||
pattern: ':period(hd|hw|hm|hy)/:packageName',
|
||||
namedParams: {
|
||||
period: 'hm',
|
||||
packageName: 'jquery',
|
||||
},
|
||||
{
|
||||
title: 'jsDelivr hits (npm scoped)',
|
||||
pattern: ':period(hd|hw|hm|hy)/:scope?/:packageName',
|
||||
namedParams: {
|
||||
period: 'hm',
|
||||
scope: '@angular',
|
||||
packageName: 'fire',
|
||||
},
|
||||
staticPreview: this.render({ period: 'hm', hits: 94123 }),
|
||||
staticPreview: this.render({ period: 'hm', hits: 920101789 }),
|
||||
},
|
||||
{
|
||||
title: 'jsDelivr hits (npm scoped)',
|
||||
pattern: ':period(hd|hw|hm|hy)/:scope?/:packageName',
|
||||
namedParams: {
|
||||
period: 'hm',
|
||||
scope: '@angular',
|
||||
packageName: 'fire',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ period: 'hm', hits: 94123 }),
|
||||
},
|
||||
]
|
||||
|
||||
async fetch({ period, packageName }) {
|
||||
return this._requestJson({
|
||||
|
||||
@@ -29,31 +29,25 @@ const bitcoinAddressSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class KeybaseBTC extends KeybaseProfile {
|
||||
static get route() {
|
||||
return {
|
||||
base: 'keybase/btc',
|
||||
pattern: ':username',
|
||||
}
|
||||
static route = {
|
||||
base: 'keybase/btc',
|
||||
pattern: ':username',
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Keybase BTC',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: '12ufRLmbEmgjsdGzhUUFY4pcfiQZyRPV9J',
|
||||
}),
|
||||
keywords: ['bitcoin'],
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Keybase BTC',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: '12ufRLmbEmgjsdGzhUUFY4pcfiQZyRPV9J',
|
||||
}),
|
||||
keywords: ['bitcoin'],
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'btc',
|
||||
color: 'informational',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'btc',
|
||||
color: 'informational',
|
||||
}
|
||||
|
||||
static render({ address }) {
|
||||
@@ -62,9 +56,7 @@ module.exports = class KeybaseBTC extends KeybaseProfile {
|
||||
}
|
||||
}
|
||||
|
||||
static get apiVersion() {
|
||||
return '1.0'
|
||||
}
|
||||
static apiVersion = '1.0'
|
||||
|
||||
async handle({ username }) {
|
||||
const options = {
|
||||
|
||||
@@ -25,28 +25,22 @@ const keyFingerprintSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class KeybasePGP extends KeybaseProfile {
|
||||
static get route() {
|
||||
return {
|
||||
base: 'keybase/pgp',
|
||||
pattern: ':username',
|
||||
}
|
||||
static route = {
|
||||
base: 'keybase/pgp',
|
||||
pattern: ':username',
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Keybase PGP',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({ fingerprint: '1863145FD39EE07E' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Keybase PGP',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({ fingerprint: '1863145FD39EE07E' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'pgp',
|
||||
color: 'informational',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'pgp',
|
||||
color: 'informational',
|
||||
}
|
||||
|
||||
static render({ fingerprint }) {
|
||||
@@ -55,9 +49,7 @@ module.exports = class KeybasePGP extends KeybaseProfile {
|
||||
}
|
||||
}
|
||||
|
||||
static get apiVersion() {
|
||||
return '1.0'
|
||||
}
|
||||
static apiVersion = '1.0'
|
||||
|
||||
async handle({ username }) {
|
||||
const options = {
|
||||
|
||||
@@ -27,31 +27,25 @@ const stellarAddressSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class KeybaseXLM extends KeybaseProfile {
|
||||
static get route() {
|
||||
return {
|
||||
base: 'keybase/xlm',
|
||||
pattern: ':username',
|
||||
}
|
||||
static route = {
|
||||
base: 'keybase/xlm',
|
||||
pattern: ':username',
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Keybase XLM',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: 'GCGH37DYONEBPGAZGCHJEZZF3J2Q3EFYZBQBE6UJL5QKTULCMEA6MXLA',
|
||||
}),
|
||||
keywords: ['stellar'],
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Keybase XLM',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: 'GCGH37DYONEBPGAZGCHJEZZF3J2Q3EFYZBQBE6UJL5QKTULCMEA6MXLA',
|
||||
}),
|
||||
keywords: ['stellar'],
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'xlm',
|
||||
color: 'informational',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'xlm',
|
||||
color: 'informational',
|
||||
}
|
||||
|
||||
static render({ address }) {
|
||||
@@ -60,9 +54,7 @@ module.exports = class KeybaseXLM extends KeybaseProfile {
|
||||
}
|
||||
}
|
||||
|
||||
static get apiVersion() {
|
||||
return '1.0'
|
||||
}
|
||||
static apiVersion = '1.0'
|
||||
|
||||
async handle({ username }) {
|
||||
const options = {
|
||||
|
||||
@@ -29,31 +29,25 @@ const zcachAddressSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class KeybaseZEC extends KeybaseProfile {
|
||||
static get route() {
|
||||
return {
|
||||
base: 'keybase/zec',
|
||||
pattern: ':username',
|
||||
}
|
||||
static route = {
|
||||
base: 'keybase/zec',
|
||||
pattern: ':username',
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Keybase ZEC',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: 't1RJDxpBcsgqAotqhepkhLFMv2XpMfvnf1y',
|
||||
}),
|
||||
keywords: ['zcash'],
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Keybase ZEC',
|
||||
namedParams: { username: 'skyplabs' },
|
||||
staticPreview: this.render({
|
||||
address: 't1RJDxpBcsgqAotqhepkhLFMv2XpMfvnf1y',
|
||||
}),
|
||||
keywords: ['zcash'],
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'zec',
|
||||
color: 'informational',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'zec',
|
||||
color: 'informational',
|
||||
}
|
||||
|
||||
static render({ address }) {
|
||||
@@ -62,9 +56,7 @@ module.exports = class KeybaseZEC extends KeybaseProfile {
|
||||
}
|
||||
}
|
||||
|
||||
static get apiVersion() {
|
||||
return '1.0'
|
||||
}
|
||||
static apiVersion = '1.0'
|
||||
|
||||
async handle({ username }) {
|
||||
const options = {
|
||||
|
||||
Reference in New Issue
Block a user