call [pepy] with auth (#9748)

This commit is contained in:
chris48s
2023-11-19 19:24:56 +00:00
committed by GitHub
parent 5ad1e35101
commit 19b50a66a6
8 changed files with 30 additions and 4 deletions

View File

@@ -20,6 +20,12 @@ export default class PepyDownloads extends BaseJsonService {
pattern: 'dt/:packageName',
}
static auth = {
passKey: 'pepy_key',
authorizedOrigins: ['https://api.pepy.tech'],
isRequired: true,
}
static openApi = {
'/pepy/dt/{packageName}': {
get: {
@@ -38,10 +44,12 @@ export default class PepyDownloads extends BaseJsonService {
static defaultBadgeData = { label: 'downloads' }
async fetch({ packageName }) {
return this._requestJson({
url: `https://api.pepy.tech/api/v2/projects/${packageName}`,
schema,
})
return this._requestJson(
this.authHelper.withApiKeyHeader({
url: `https://api.pepy.tech/api/v2/projects/${packageName}`,
schema,
}),
)
}
async handle({ packageName }) {