Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Nov 27, 2023
1 parent 3d60839 commit ea59bd4
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 84 deletions.
27 changes: 14 additions & 13 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { $fetch } from 'ofetch'
import type { ClientConfig, ClientResponse, NoResponse, UserRes } from './types'
import { monitorManager, projectsManager, servicesManager, settingsManager } from './managers'
import { Routes } from './utils/Routes'
import { monitor, projects, services, settings } from './service'
import { routes } from './utils/routes'

let token = ''

Expand Down Expand Up @@ -48,35 +48,36 @@ function client(config: ClientConfig): ClientResponse {
export function easypanel(config: ClientConfig) {
const _client = client(config)

const projects = projectsManager(_client)
const services = servicesManager(_client)
const monitor = monitorManager(_client)
const settings = settingsManager(_client)
const _projects = projects(_client)
const _services = services(_client)
const _monitor = monitor(_client)
const _settings = settings(_client)

async function getUser(): Promise<UserRes> {
const res = await _client.get<UserRes>(Routes.Auth.GetUser, { json: null })
const res = await _client.get<UserRes>(routes.auth.GetUser, { json: null })
return res
}

async function getLicensePayload(type: 'lemon' | 'portal'): Promise<NoResponse> {
const res = await _client.get<NoResponse>(Routes.License(type).Get, { json: null })
const res = await _client.get<NoResponse>(routes.license(type).Get, { json: null })
return res
}

async function activateLicense(type: 'lemon' | 'portal'): Promise<NoResponse> {
const res = await _client.post<NoResponse>(Routes.License(type).Activate, {
const res = await _client.post<NoResponse>(routes.license(type).Activate, {
json: null,
})
return res
}

return {
projects,
services,
monitor,
settings,
projects: _projects,
services: _services,
monitor: _monitor,
settings: _settings,
getUser,
getLicensePayload,
activateLicense,
token: _client.token,
}
}
4 changes: 0 additions & 4 deletions src/managers/index.ts

This file was deleted.

4 changes: 4 additions & 0 deletions src/service/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './projects'
export * from './monitors'
export * from './settings'
export * from './services'
12 changes: 6 additions & 6 deletions src/managers/MonitorManager.ts → src/service/monitors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ import type {
SystemStats,
} from '../types/monitor'
import type { ClientResponse } from '../types'
import { Routes } from '../utils/Routes'
import { routes } from '../utils/routes'

export function monitorManager({ get }: ClientResponse) {
export function monitor({ get }: ClientResponse) {
async function getAdvancedStats() {
const res = await get<AdvancedStats>(Routes.Monitor.GetAdvancedStats, {
const res = await get<AdvancedStats>(routes.monitor.GetAdvancedStats, {
json: null,
})
return res
}

async function getDockerTaskStats() {
const res = await get<DockerTaskStats>(Routes.Monitor.GetDockerTaskStats, {
const res = await get<DockerTaskStats>(routes.monitor.GetDockerTaskStats, {
json: null,
})
return res
}

async function getMonitorTableData() {
const res = await get<ContainerStats>(Routes.Monitor.GetMonitorTableData, {
const res = await get<ContainerStats>(routes.monitor.GetMonitorTableData, {
json: null,
})
return res
}

async function getSystemStats() {
const res = await get<SystemStats>(Routes.Monitor.GetSystemStats, {
const res = await get<SystemStats>(routes.monitor.GetSystemStats, {
json: null,
})
return res
Expand Down
16 changes: 8 additions & 8 deletions src/managers/ProjectsManager.ts → src/service/projects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Routes } from '../utils/Routes'
import { routes } from '../utils/routes'

import type {
CanCreate,
Expand All @@ -12,45 +12,45 @@ import type {
ProjectQueryConf,
} from '../types'

export function projectsManager({ get, post }: ClientResponse) {
export function projects({ get, post }: ClientResponse) {
async function canCreate() {
const res = await get<CanCreate>(Routes.Projets.CanCreate, {
const res = await get<CanCreate>(routes.projets.CanCreate, {
json: null,
})
return res
}

async function create(body: ProjectName) {
const Route = Routes.Projets.Create.replace('app', body.name)
const Route = routes.projets.Create.replace('app', body.name)
const res = await post<Create>(Route, {
json: body,
})
return res
}

async function destory(body: ProjectName) {
const res = await post<NoResponse>(Routes.Projets.Destroy, {
const res = await post<NoResponse>(routes.projets.Destroy, {
json: body,
})
return res
}

async function inspect(body: ProjectQueryConf) {
const res = await get<Project>(Routes.Projets.Inspect, {
const res = await get<Project>(routes.projets.Inspect, {
json: body,
})
return res
}

async function list() {
const res = await get<ListProjects>(Routes.Projets.List, {
const res = await get<ListProjects>(routes.projets.List, {
json: null,
})
return res
}

async function listWithServices() {
const res = await get<ListWithServices>(Routes.Projets.ListWithServices, {
const res = await get<ListWithServices>(routes.projets.ListWithServices, {
json: null,
})
return res
Expand Down
44 changes: 22 additions & 22 deletions src/managers/ServicesManager.ts → src/service/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import type {
UpdateRedirects,
UpdateResources,
} from '../types/services'
import { Routes } from '../utils/Routes'
import { routes } from '../utils/routes'

export function servicesManager({ get, post }: ClientResponse) {
export function services({ get, post }: ClientResponse) {
/**
* Creates a new service.
*/
Expand All @@ -31,7 +31,7 @@ export function servicesManager({ get, post }: ClientResponse) {
host: '$(EASYPANEL_DOMAIN)',
},
]
const Route = Routes.Services(serviceType).Create
const Route = routes.services(serviceType).Create
const res = await post<ServiceRes>(Route, { json: body })
return res
}
Expand All @@ -43,7 +43,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: SelectService,
) {
const Route = Routes.Services(serviceType).Inspect
const Route = routes.services(serviceType).Inspect
const res = await get<ServiceRes>(Route, { json: body })
return res
}
Expand All @@ -55,7 +55,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: SelectService,
) {
const Route = Routes.Services(serviceType).Destroy
const Route = routes.services(serviceType).Destroy
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -67,7 +67,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: SelectService,
) {
const Route = Routes.Services(serviceType).Deploy
const Route = routes.services(serviceType).Deploy
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -79,7 +79,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: SelectService,
) {
const Route = Routes.Services(serviceType).Disable
const Route = routes.services(serviceType).Disable
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -91,7 +91,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: SelectService,
) {
const Route = Routes.Services(serviceType).Enable
const Route = routes.services(serviceType).Enable
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -103,7 +103,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: SelectService,
) {
const Route = Routes.Services(serviceType).RefreshDeployToken
const Route = routes.services(serviceType).RefreshDeployToken
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -115,7 +115,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdateGithub,
) {
const Route = Routes.Services(serviceType).UpdateSourceGithub
const Route = routes.services(serviceType).UpdateSourceGithub
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -127,7 +127,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdateGit,
) {
const Route = Routes.Services(serviceType).UpdateSourceGit
const Route = routes.services(serviceType).UpdateSourceGit
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -139,7 +139,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdateImage,
) {
const Route = Routes.Services(serviceType).UpdateSourceImage
const Route = routes.services(serviceType).UpdateSourceImage
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -151,7 +151,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdateBuild,
) {
const Route = Routes.Services(serviceType).UpdateBuild
const Route = routes.services(serviceType).UpdateBuild
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -163,7 +163,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdateEnv,
) {
const Route = Routes.Services(serviceType).UpdateEnv
const Route = routes.services(serviceType).UpdateEnv
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -175,7 +175,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: CreateService,
) {
const Route = Routes.Services(serviceType).UpdateDomains
const Route = routes.services(serviceType).UpdateDomains
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -187,7 +187,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdateRedirects,
) {
const Route = Routes.Services(serviceType).UpdateRedirects
const Route = routes.services(serviceType).UpdateRedirects
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -199,7 +199,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdateBasicAuth,
) {
const Route = Routes.Services(serviceType).UpdateBasicAuth
const Route = routes.services(serviceType).UpdateBasicAuth
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -211,7 +211,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: MountParams,
) {
const Route = Routes.Services(serviceType).UpdateMounts
const Route = routes.services(serviceType).UpdateMounts
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -223,7 +223,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdatePorts,
) {
const Route = Routes.Services(serviceType).UpdatePorts
const Route = routes.services(serviceType).UpdatePorts
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -235,7 +235,7 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: UpdateResources,
) {
const Route = Routes.Services(serviceType).UpdateResources
const Route = routes.services(serviceType).UpdateResources
const res = await post<NoResponse>(Route, { json: body })
return res
}
Expand All @@ -247,14 +247,14 @@ export function servicesManager({ get, post }: ClientResponse) {
serviceType: ServiceType,
body: DeployParams,
) {
const Route = Routes.Services(serviceType).UpdateDeploy
const Route = routes.services(serviceType).UpdateDeploy
const res = await post<NoResponse>(Route, { json: body })
return res
}

async function getServiceLogs(body: SelectService) {
const service = `${body.projectName}_${body.serviceName}`
const res = await get<StringResponse>(Routes.Services('').GetServiceLogs, {
const res = await get<StringResponse>(routes.services('').GetServiceLogs, {
json: {
service,
lines: 50,
Expand Down
Loading

0 comments on commit ea59bd4

Please sign in to comment.