Skip to content

Commit

Permalink
feat: better api
Browse files Browse the repository at this point in the history
  • Loading branch information
futrime committed Nov 7, 2024
1 parent 38cecc1 commit 8f539e4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion apps/bot/endstone-cpp-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class EndstoneCppFetcher extends GitHubFetcher {

const contributors: Contributor[] = repositoryContributors.map<Contributor>(contributor => ({
username: contributor.login ?? '',
avatarUrl: contributor.avatar_url,
contributions: contributor.contributions
}))

Expand Down
1 change: 0 additions & 1 deletion apps/bot/endstone-python-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class EndstonePythonFetcher extends GitHubFetcher {

const contributors: Contributor[] = repositoryContributors.map<Contributor>(contributor => ({
username: contributor.login ?? '',
avatarUrl: contributor.avatar_url,
contributions: contributor.contributions
}))

Expand Down
1 change: 0 additions & 1 deletion apps/bot/levilamina-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class LeviLaminaFetcher extends GitHubFetcher {

const contributors: Contributor[] = repositoryContributors.map<Contributor>(contributor => ({
username: contributor.login ?? '',
avatarUrl: contributor.avatar_url,
contributions: contributor.contributions
}))

Expand Down
1 change: 0 additions & 1 deletion apps/bot/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface Package {

export interface Contributor {
username: string
avatarUrl?: string
contributions: number
}

Expand Down
6 changes: 3 additions & 3 deletions apps/bot/redis-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const schema = new Schema('package', {
avatarUrl: { type: 'string' },
hotness: { type: 'number', sortable: true },
updated: { type: 'string' },
contributors_username: { type: 'string[]', path: '$.contributors[*].username' },
contributors_contributions: { type: 'number[]', path: '$.contributors[*].contributions' },
versions_version: { type: 'string[]', path: '$.versions[*].version' },
versions_releasedAt: { type: 'string[]', path: '$.versions[*].releasedAt' },
versions_source: { type: 'string[]', path: '$.versions[*].source' },
versions_packageManager: { type: 'string[]', path: '$.versions[*].packageManager' }
})

const reconnectTimeout = 500

export class RedisClient implements DatabaseClient {
private readonly client: RedisClientType
private readonly repository: Repository
Expand All @@ -29,7 +29,7 @@ export class RedisClient implements DatabaseClient {
this.client = createClient({
url,
socket: {
reconnectStrategy: () => reconnectTimeout
reconnectStrategy: () => 500
}
})
this.client.on('error', (err) => {
Expand Down
13 changes: 13 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ paths:
- "$ref": "#/components/schemas/PackageInfo"
- type: object
properties:
contributors:
type: array
items:
type: object
properties:
username:
type: string
contributions:
type: number
required:
- username
- contributions
versions:
type: array
items:
Expand All @@ -137,6 +149,7 @@ paths:
- source
- packageManager
required:
- contributors
- versions
required:
- apiVersion
Expand Down

0 comments on commit 8f539e4

Please sign in to comment.