convert some service classes to static props, run [cdnjs chromewebstore] (#5509)
* refactor(cdnjs): convert to static props * refactor(chromewebstore): convert to static props Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -10,29 +10,17 @@ const cdnjsSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class Cdnjs extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
static category = 'version'
|
||||
static route = { base: 'cdnjs/v', pattern: ':library' }
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'cdnjs/v',
|
||||
pattern: ':library',
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
namedParams: { library: 'jquery' },
|
||||
staticPreview: this.render({ version: '1.5.2' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
namedParams: { library: 'jquery' },
|
||||
staticPreview: this.render({ version: '1.5.2' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'cdnjs' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'cdnjs' }
|
||||
|
||||
static render({ version }) {
|
||||
return renderVersionBadge({ version })
|
||||
|
||||
@@ -4,30 +4,18 @@ const { currencyFromCode } = require('../text-formatters')
|
||||
const BaseChromeWebStoreService = require('./chrome-web-store-base')
|
||||
|
||||
module.exports = class ChromeWebStorePrice extends BaseChromeWebStoreService {
|
||||
static get category() {
|
||||
return 'funding'
|
||||
}
|
||||
static category = 'funding'
|
||||
static route = { base: 'chrome-web-store/price', pattern: ':storeId' }
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'chrome-web-store/price',
|
||||
pattern: ':storeId',
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Chrome Web Store',
|
||||
namedParams: { storeId: 'ogffaloegjglncjfehdfplabnoondfjo' },
|
||||
staticPreview: this.render({ priceCurrency: 'USD', price: 0 }),
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Chrome Web Store',
|
||||
namedParams: { storeId: 'ogffaloegjglncjfehdfplabnoondfjo' },
|
||||
staticPreview: this.render({ priceCurrency: 'USD', price: 0 }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'price' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'price' }
|
||||
|
||||
static render({ priceCurrency, price }) {
|
||||
return {
|
||||
|
||||
@@ -6,30 +6,18 @@ const { redirector, NotFound } = require('..')
|
||||
const BaseChromeWebStoreService = require('./chrome-web-store-base')
|
||||
|
||||
class ChromeWebStoreUsers extends BaseChromeWebStoreService {
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
static category = 'downloads'
|
||||
static route = { base: 'chrome-web-store/users', pattern: ':storeId' }
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'chrome-web-store/users',
|
||||
pattern: ':storeId',
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Chrome Web Store',
|
||||
namedParams: { storeId: 'ogffaloegjglncjfehdfplabnoondfjo' },
|
||||
staticPreview: this.render({ downloads: 573 }),
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Chrome Web Store',
|
||||
namedParams: { storeId: 'ogffaloegjglncjfehdfplabnoondfjo' },
|
||||
staticPreview: this.render({ downloads: 573 }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'users' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'users' }
|
||||
|
||||
static render({ downloads }) {
|
||||
return {
|
||||
|
||||
@@ -4,30 +4,18 @@ const { renderVersionBadge } = require('../version')
|
||||
const BaseChromeWebStoreService = require('./chrome-web-store-base')
|
||||
|
||||
module.exports = class ChromeWebStoreVersion extends BaseChromeWebStoreService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
static category = 'version'
|
||||
static route = { base: 'chrome-web-store/v', pattern: ':storeId' }
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'chrome-web-store/v',
|
||||
pattern: ':storeId',
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Chrome Web Store',
|
||||
namedParams: { storeId: 'ogffaloegjglncjfehdfplabnoondfjo' },
|
||||
staticPreview: renderVersionBadge({ version: 'v1.1.0' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Chrome Web Store',
|
||||
namedParams: { storeId: 'ogffaloegjglncjfehdfplabnoondfjo' },
|
||||
staticPreview: renderVersionBadge({ version: 'v1.1.0' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'chrome web store' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'chrome web store' }
|
||||
|
||||
async handle({ storeId }) {
|
||||
const data = await this.fetch({ storeId })
|
||||
|
||||
Reference in New Issue
Block a user