You've already forked AstralRinth
forked from didirus/AstralRinth
feat: base api-client impl (#4694)
* feat: base api-client impl * fix: doc * feat: start work on module stuff * feat: migrate v2/v3 projects into module system * fix: lint & README.md contributing * refactor: remove utils old api client prototype * fix: lint * fix: api url issues * fix: baseurl in error.vue * fix: readme * fix typo in readme * Update apps/frontend/src/providers/api-client.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Calum H. <hendersoncal117@gmail.com> * Update packages/api-client/src/features/verbose-logging.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Calum H. <hendersoncal117@gmail.com> * Update packages/api-client/src/features/retry.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Calum H. <hendersoncal117@gmail.com> --------- Signed-off-by: Calum H. <hendersoncal117@gmail.com> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
import type { Project, ProjectV3Partial } from '../types'
|
||||
import type { ModrinthApi } from './index'
|
||||
import type { ModrinthApiProjects, ProjectEditBody, ProjectV3EditBodyPartial } from './projects'
|
||||
|
||||
export class RestModrinthApi implements ModrinthApi {
|
||||
projects: ModrinthApiProjects
|
||||
|
||||
constructor(requestApi: (url: string, options?: object) => Promise<Response>) {
|
||||
this.projects = new RestModrinthApiProjects(requestApi)
|
||||
}
|
||||
}
|
||||
|
||||
class RestModrinthApiProjects implements ModrinthApiProjects {
|
||||
constructor(private request: (url: string, options?: object) => Promise<Response>) {}
|
||||
|
||||
async get(id: string): Promise<Project> {
|
||||
const res = await this.request(`/v2/project/${id}`)
|
||||
return res.json()
|
||||
}
|
||||
|
||||
async getV3(id: string): Promise<ProjectV3Partial> {
|
||||
const res = await this.request(`/v3/project/${id}`)
|
||||
return res.json()
|
||||
}
|
||||
|
||||
async edit(id: string, data: ProjectEditBody): Promise<void> {
|
||||
await this.request(`/v2/project/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
}
|
||||
|
||||
async editV3(id: string, data: ProjectV3EditBodyPartial): Promise<void> {
|
||||
await this.request(`/v3/project/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import type { ModrinthApiProjects } from './projects'
|
||||
|
||||
export interface ModrinthApi {
|
||||
projects: ModrinthApiProjects
|
||||
}
|
||||
|
||||
export { RestModrinthApi } from './default_impl'
|
||||
@@ -1,41 +0,0 @@
|
||||
import type {
|
||||
DonationLink,
|
||||
DonationPlatform,
|
||||
Environment,
|
||||
EnvironmentMigrationReviewStatus,
|
||||
EnvironmentV3,
|
||||
Project,
|
||||
ProjectStatus,
|
||||
ProjectV3Partial,
|
||||
RequestableStatus,
|
||||
} from '../types'
|
||||
|
||||
export type ProjectEditBody = {
|
||||
slug?: string
|
||||
title?: string
|
||||
description?: string
|
||||
categories?: string[]
|
||||
client_side?: Environment
|
||||
server_side?: Environment
|
||||
status?: ProjectStatus
|
||||
requested_status?: RequestableStatus
|
||||
additional_categories?: string[]
|
||||
issues_url?: string
|
||||
source_url?: string
|
||||
wiki_url?: string
|
||||
discord_url?: string
|
||||
donation_urls?: DonationLink<DonationPlatform>[]
|
||||
license_id?: string
|
||||
license_url?: string
|
||||
}
|
||||
export type ProjectV3EditBodyPartial = {
|
||||
environment?: EnvironmentV3
|
||||
side_types_migration_review_status: EnvironmentMigrationReviewStatus
|
||||
}
|
||||
|
||||
export interface ModrinthApiProjects {
|
||||
get(id: string): Promise<Project>
|
||||
getV3(id: string): Promise<ProjectV3Partial>
|
||||
edit(id: string, data: ProjectEditBody): Promise<void>
|
||||
editV3(id: string, data: ProjectV3EditBodyPartial): Promise<void>
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
export * from './api'
|
||||
export * from './billing'
|
||||
export * from './changelog'
|
||||
export * from './highlightjs'
|
||||
|
||||
Reference in New Issue
Block a user