-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chrome-webstore-size-last-updated
- Loading branch information
Showing
14 changed files
with
191 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,7 @@ processes = [] | |
interval = "15s" | ||
restart_limit = 0 | ||
timeout = "2s" | ||
|
||
[[vm]] | ||
size = "shared-cpu-1x" | ||
memory = "256mb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { renderDownloadsBadge } from '../downloads.js' | ||
import { pathParams } from '../index.js' | ||
import { BaseCratesUserService, description } from './crates-base.js' | ||
|
||
export default class CratesUserDownloads extends BaseCratesUserService { | ||
static category = 'downloads' | ||
static route = { | ||
base: 'crates', | ||
pattern: 'udt/:userId', | ||
} | ||
|
||
static openApi = { | ||
'/crates/udt/{userId}': { | ||
get: { | ||
summary: 'Crates.io User Total Downloads', | ||
description, | ||
parameters: pathParams({ | ||
name: 'userId', | ||
example: '3027', | ||
description: | ||
'The user ID can be found using `https://crates.io/api/v1/users/{username}`', | ||
}), | ||
}, | ||
}, | ||
} | ||
|
||
async handle({ userId }) { | ||
const json = await this.fetch({ userId }) | ||
const { total_downloads: downloads } = json | ||
return renderDownloadsBadge({ downloads, labelOverride: 'downloads' }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { isMetric } from '../test-validators.js' | ||
import { createServiceTester } from '../tester.js' | ||
export const t = await createServiceTester() | ||
|
||
t.create('total user downloads') | ||
.get('/udt/3027.json') | ||
.expectBadge({ label: 'downloads', message: isMetric }) | ||
|
||
// non-existent user returns 0 downloads with 200 OK status code rather than 404. | ||
t.create('total user downloads (user not found)') | ||
.get('/udt/2147483647.json') // 2147483647 is the maximum valid user id as API uses i32 | ||
.expectBadge({ label: 'downloads', message: '0' }) | ||
|
||
t.create('total user downloads (invalid)') | ||
.get('/udt/999999999999999999999999.json') | ||
.expectBadge({ label: 'crates.io', message: 'invalid' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,11 @@ | ||
import { BaseService, pathParams } from '../index.js' | ||
import { deprecatedService } from '../index.js' | ||
|
||
export default class HackageDeps extends BaseService { | ||
static category = 'dependencies' | ||
|
||
static route = { | ||
export const HackageDeps = deprecatedService({ | ||
category: 'dependencies', | ||
route: { | ||
base: 'hackage-deps/v', | ||
pattern: ':packageName', | ||
} | ||
|
||
static openApi = { | ||
'/hackage-deps/v/{packageName}': { | ||
get: { | ||
summary: 'Hackage Dependencies', | ||
parameters: pathParams({ | ||
name: 'packageName', | ||
example: 'lens', | ||
}), | ||
}, | ||
}, | ||
} | ||
|
||
static defaultBadgeData = { label: 'dependencies' } | ||
|
||
static render({ isOutdated }) { | ||
if (isOutdated) { | ||
return { message: 'outdated', color: 'orange' } | ||
} else { | ||
return { message: 'up to date', color: 'brightgreen' } | ||
} | ||
} | ||
|
||
async handle({ packageName }) { | ||
const reverseUrl = `http://packdeps.haskellers.com/licenses/${packageName}` | ||
const feedUrl = `http://packdeps.haskellers.com/feed/${packageName}` | ||
|
||
// first call /reverse to check if the package exists | ||
// this will throw a 404 if it doesn't | ||
await this._request({ url: reverseUrl }) | ||
|
||
// if the package exists, then query /feed to check the dependencies | ||
const { buffer } = await this._request({ url: feedUrl }) | ||
|
||
const outdatedStr = `Outdated dependencies for ${packageName} ` | ||
const isOutdated = buffer.includes(outdatedStr) | ||
return this.constructor.render({ isOutdated }) | ||
} | ||
} | ||
}, | ||
label: 'hackagedeps', | ||
dateAdded: new Date('2024-10-18'), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
import Joi from 'joi' | ||
import { createServiceTester } from '../tester.js' | ||
export const t = await createServiceTester() | ||
import { ServiceTester } from '../tester.js' | ||
export const t = new ServiceTester({ | ||
id: 'hackagedeps', | ||
title: 'Hackage Dependencies', | ||
pathPrefix: '/hackage-deps/v', | ||
}) | ||
|
||
t.create('hackage deps (valid)') | ||
.get('/lens.json') | ||
.expectBadge({ | ||
label: 'dependencies', | ||
message: Joi.string().regex(/^(up to date|outdated)$/), | ||
}) | ||
|
||
t.create('hackage deps (not found)') | ||
.get('/not-a-package.json') | ||
.expectBadge({ label: 'dependencies', message: 'not found' }) | ||
t.create('hackage deps (deprecated)') | ||
.get('/package.json') | ||
.expectBadge({ label: 'hackagedeps', message: 'no longer available' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.