mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-10-04 11:50:09 +00:00
API lib cleanup, 404 hosts WIP
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
import * as api from "./base";
|
||||
import type { AccessList } from "./models";
|
||||
|
||||
export async function createAccessList(item: AccessList, abortController?: AbortController): Promise<AccessList> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/nginx/access-lists",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function createAccessList(item: AccessList): Promise<AccessList> {
|
||||
return await api.post({
|
||||
url: "/nginx/access-lists",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
});
|
||||
}
|
||||
|
@@ -1,13 +1,10 @@
|
||||
import * as api from "./base";
|
||||
import type { Certificate } from "./models";
|
||||
|
||||
export async function createCertificate(item: Certificate, abortController?: AbortController): Promise<Certificate> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/nginx/certificates",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function createCertificate(item: Certificate): Promise<Certificate> {
|
||||
return await api.post({
|
||||
url: "/nginx/certificates",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
});
|
||||
}
|
||||
|
@@ -1,13 +1,10 @@
|
||||
import * as api from "./base";
|
||||
import type { DeadHost } from "./models";
|
||||
|
||||
export async function createDeadHost(item: DeadHost, abortController?: AbortController): Promise<DeadHost> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/nginx/dead-hosts",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function createDeadHost(item: DeadHost): Promise<DeadHost> {
|
||||
return await api.post({
|
||||
url: "/nginx/dead-hosts",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
});
|
||||
}
|
||||
|
@@ -1,13 +1,10 @@
|
||||
import * as api from "./base";
|
||||
import type { ProxyHost } from "./models";
|
||||
|
||||
export async function createProxyHost(item: ProxyHost, abortController?: AbortController): Promise<ProxyHost> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/nginx/proxy-hosts",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function createProxyHost(item: ProxyHost): Promise<ProxyHost> {
|
||||
return await api.post({
|
||||
url: "/nginx/proxy-hosts",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
});
|
||||
}
|
||||
|
@@ -1,16 +1,10 @@
|
||||
import * as api from "./base";
|
||||
import type { RedirectionHost } from "./models";
|
||||
|
||||
export async function createRedirectionHost(
|
||||
item: RedirectionHost,
|
||||
abortController?: AbortController,
|
||||
): Promise<RedirectionHost> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/nginx/redirection-hosts",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function createRedirectionHost(item: RedirectionHost): Promise<RedirectionHost> {
|
||||
return await api.post({
|
||||
url: "/nginx/redirection-hosts",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
});
|
||||
}
|
||||
|
@@ -1,13 +1,10 @@
|
||||
import * as api from "./base";
|
||||
import type { Stream } from "./models";
|
||||
|
||||
export async function createStream(item: Stream, abortController?: AbortController): Promise<Stream> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/nginx/streams",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function createStream(item: Stream): Promise<Stream> {
|
||||
return await api.post({
|
||||
url: "/nginx/streams",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
});
|
||||
}
|
||||
|
@@ -15,14 +15,11 @@ export interface NewUser {
|
||||
roles?: string[];
|
||||
}
|
||||
|
||||
export async function createUser(item: NewUser, noAuth?: boolean, abortController?: AbortController): Promise<User> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/users",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
noAuth,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function createUser(item: NewUser, noAuth?: boolean): Promise<User> {
|
||||
return await api.post({
|
||||
url: "/users",
|
||||
// todo: only use whitelist of fields for this data
|
||||
data: item,
|
||||
noAuth,
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function deleteAccessList(id: number, abortController?: AbortController): Promise<boolean> {
|
||||
return await api.del(
|
||||
{
|
||||
url: `/nginx/access-lists/${id}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function deleteAccessList(id: number): Promise<boolean> {
|
||||
return await api.del({
|
||||
url: `/nginx/access-lists/${id}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function deleteCertificate(id: number, abortController?: AbortController): Promise<boolean> {
|
||||
return await api.del(
|
||||
{
|
||||
url: `/nginx/certificates/${id}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function deleteCertificate(id: number): Promise<boolean> {
|
||||
return await api.del({
|
||||
url: `/nginx/certificates/${id}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function deleteDeadHost(id: number, abortController?: AbortController): Promise<boolean> {
|
||||
return await api.del(
|
||||
{
|
||||
url: `/nginx/dead-hosts/${id}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function deleteDeadHost(id: number): Promise<boolean> {
|
||||
return await api.del({
|
||||
url: `/nginx/dead-hosts/${id}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function deleteProxyHost(id: number, abortController?: AbortController): Promise<boolean> {
|
||||
return await api.del(
|
||||
{
|
||||
url: `/nginx/proxy-hosts/${id}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function deleteProxyHost(id: number): Promise<boolean> {
|
||||
return await api.del({
|
||||
url: `/nginx/proxy-hosts/${id}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function deleteRedirectionHost(id: number, abortController?: AbortController): Promise<boolean> {
|
||||
return await api.del(
|
||||
{
|
||||
url: `/nginx/redirection-hosts/${id}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function deleteRedirectionHost(id: number): Promise<boolean> {
|
||||
return await api.del({
|
||||
url: `/nginx/redirection-hosts/${id}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function deleteStream(id: number, abortController?: AbortController): Promise<boolean> {
|
||||
return await api.del(
|
||||
{
|
||||
url: `/nginx/streams/${id}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function deleteStream(id: number): Promise<boolean> {
|
||||
return await api.del({
|
||||
url: `/nginx/streams/${id}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function deleteUser(id: number, abortController?: AbortController): Promise<boolean> {
|
||||
return await api.del(
|
||||
{
|
||||
url: `/users/${id}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function deleteUser(id: number): Promise<boolean> {
|
||||
return await api.del({
|
||||
url: `/users/${id}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,11 +1,8 @@
|
||||
import * as api from "./base";
|
||||
import type { Binary } from "./responseTypes";
|
||||
|
||||
export async function downloadCertificate(id: number, abortController?: AbortController): Promise<Binary> {
|
||||
return await api.get(
|
||||
{
|
||||
url: `/nginx/certificates/${id}/download`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function downloadCertificate(id: number): Promise<Binary> {
|
||||
return await api.get({
|
||||
url: `/nginx/certificates/${id}/download`,
|
||||
});
|
||||
}
|
||||
|
6
frontend/src/api/backend/expansions.ts
Normal file
6
frontend/src/api/backend/expansions.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export type AccessListExpansion = "owner" | "items" | "clients";
|
||||
export type AuditLogExpansion = "user";
|
||||
export type CertificateExpansion = "owner" | "proxy_hosts" | "redirection_hosts" | "dead_hosts";
|
||||
export type HostExpansion = "owner" | "certificate";
|
||||
export type ProxyHostExpansion = "owner" | "access_list" | "certificate";
|
||||
export type UserExpansion = "permissions";
|
@@ -1,11 +1,13 @@
|
||||
import * as api from "./base";
|
||||
import type { AccessListExpansion } from "./expansions";
|
||||
import type { AccessList } from "./models";
|
||||
|
||||
export async function getAccessList(id: number, abortController?: AbortController): Promise<AccessList> {
|
||||
return await api.get(
|
||||
{
|
||||
url: `/nginx/access-lists/${id}`,
|
||||
export async function getAccessList(id: number, expand?: AccessListExpansion[], params = {}): Promise<AccessList> {
|
||||
return await api.get({
|
||||
url: `/nginx/access-lists/${id}`,
|
||||
params: {
|
||||
expand: expand?.join(","),
|
||||
...params,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import * as api from "./base";
|
||||
import type { AccessListExpansion } from "./expansions";
|
||||
import type { AccessList } from "./models";
|
||||
|
||||
export type AccessListExpansion = "owner" | "items" | "clients";
|
||||
|
||||
export async function getAccessLists(expand?: AccessListExpansion[], params = {}): Promise<AccessList[]> {
|
||||
return await api.get({
|
||||
url: "/nginx/access-lists",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import * as api from "./base";
|
||||
import type { AuditLogExpansion } from "./getAuditLogs";
|
||||
import type { AuditLogExpansion } from "./expansions";
|
||||
import type { AuditLog } from "./models";
|
||||
|
||||
export async function getAuditLog(id: number, expand?: AuditLogExpansion[], params = {}): Promise<AuditLog> {
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import * as api from "./base";
|
||||
import type { AuditLogExpansion } from "./expansions";
|
||||
import type { AuditLog } from "./models";
|
||||
|
||||
export type AuditLogExpansion = "user";
|
||||
|
||||
export async function getAuditLogs(expand?: AuditLogExpansion[], params = {}): Promise<AuditLog[]> {
|
||||
return await api.get({
|
||||
url: "/audit-log",
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import * as api from "./base";
|
||||
import type { CertificateExpansion } from "./expansions";
|
||||
import type { Certificate } from "./models";
|
||||
|
||||
export async function getCertificate(id: number, abortController?: AbortController): Promise<Certificate> {
|
||||
return await api.get(
|
||||
{
|
||||
url: `/nginx/certificates/${id}`,
|
||||
export async function getCertificate(id: number, expand?: CertificateExpansion[], params = {}): Promise<Certificate> {
|
||||
return await api.get({
|
||||
url: `/nginx/certificates/${id}`,
|
||||
params: {
|
||||
expand: expand?.join(","),
|
||||
...params,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import * as api from "./base";
|
||||
import type { CertificateExpansion } from "./expansions";
|
||||
import type { Certificate } from "./models";
|
||||
|
||||
export type CertificateExpansion = "owner" | "proxy_hosts" | "redirection_hosts" | "dead_hosts";
|
||||
|
||||
export async function getCertificates(expand?: CertificateExpansion[], params = {}): Promise<Certificate[]> {
|
||||
return await api.get({
|
||||
url: "/nginx/certificates",
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import * as api from "./base";
|
||||
import type { HostExpansion } from "./expansions";
|
||||
import type { DeadHost } from "./models";
|
||||
|
||||
export async function getDeadHost(id: number, abortController?: AbortController): Promise<DeadHost> {
|
||||
return await api.get(
|
||||
{
|
||||
url: `/nginx/dead-hosts/${id}`,
|
||||
export async function getDeadHost(id: number, expand?: HostExpansion[], params = {}): Promise<DeadHost> {
|
||||
return await api.get({
|
||||
url: `/nginx/dead-hosts/${id}`,
|
||||
params: {
|
||||
expand: expand?.join(","),
|
||||
...params,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import * as api from "./base";
|
||||
import type { HostExpansion } from "./expansions";
|
||||
import type { DeadHost } from "./models";
|
||||
|
||||
export type DeadHostExpansion = "owner" | "certificate";
|
||||
|
||||
export async function getDeadHosts(expand?: DeadHostExpansion[], params = {}): Promise<DeadHost[]> {
|
||||
export async function getDeadHosts(expand?: HostExpansion[], params = {}): Promise<DeadHost[]> {
|
||||
return await api.get({
|
||||
url: "/nginx/dead-hosts",
|
||||
params: {
|
||||
|
@@ -1,11 +1,8 @@
|
||||
import * as api from "./base";
|
||||
import type { HealthResponse } from "./responseTypes";
|
||||
|
||||
export async function getHealth(abortController?: AbortController): Promise<HealthResponse> {
|
||||
return await api.get(
|
||||
{
|
||||
url: "/",
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function getHealth(): Promise<HealthResponse> {
|
||||
return await api.get({
|
||||
url: "/",
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function getHostsReport(abortController?: AbortController): Promise<Record<string, number>> {
|
||||
return await api.get(
|
||||
{
|
||||
url: "/reports/hosts",
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function getHostsReport(): Promise<Record<string, number>> {
|
||||
return await api.get({
|
||||
url: "/reports/hosts",
|
||||
});
|
||||
}
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import * as api from "./base";
|
||||
import type { ProxyHostExpansion } from "./expansions";
|
||||
import type { ProxyHost } from "./models";
|
||||
|
||||
export async function getProxyHost(id: number, abortController?: AbortController): Promise<ProxyHost> {
|
||||
return await api.get(
|
||||
{
|
||||
url: `/nginx/proxy-hosts/${id}`,
|
||||
export async function getProxyHost(id: number, expand?: ProxyHostExpansion[], params = {}): Promise<ProxyHost> {
|
||||
return await api.get({
|
||||
url: `/nginx/proxy-hosts/${id}`,
|
||||
params: {
|
||||
expand: expand?.join(","),
|
||||
...params,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import * as api from "./base";
|
||||
import type { ProxyHostExpansion } from "./expansions";
|
||||
import type { ProxyHost } from "./models";
|
||||
|
||||
export type ProxyHostExpansion = "owner" | "access_list" | "certificate";
|
||||
|
||||
export async function getProxyHosts(expand?: ProxyHostExpansion[], params = {}): Promise<ProxyHost[]> {
|
||||
return await api.get({
|
||||
url: "/nginx/proxy-hosts",
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import * as api from "./base";
|
||||
import type { HostExpansion } from "./expansions";
|
||||
import type { ProxyHost } from "./models";
|
||||
|
||||
export async function getRedirectionHost(id: number, abortController?: AbortController): Promise<ProxyHost> {
|
||||
return await api.get(
|
||||
{
|
||||
url: `/nginx/redirection-hosts/${id}`,
|
||||
export async function getRedirectionHost(id: number, expand?: HostExpansion[], params = {}): Promise<ProxyHost> {
|
||||
return await api.get({
|
||||
url: `/nginx/redirection-hosts/${id}`,
|
||||
params: {
|
||||
expand: expand?.join(","),
|
||||
...params,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -1,11 +1,8 @@
|
||||
import * as api from "./base";
|
||||
import type { HostExpansion } from "./expansions";
|
||||
import type { RedirectionHost } from "./models";
|
||||
|
||||
export type RedirectionHostExpansion = "owner" | "certificate";
|
||||
export async function getRedirectionHosts(
|
||||
expand?: RedirectionHostExpansion[],
|
||||
params = {},
|
||||
): Promise<RedirectionHost[]> {
|
||||
export async function getRedirectionHosts(expand?: HostExpansion[], params = {}): Promise<RedirectionHost[]> {
|
||||
return await api.get({
|
||||
url: "/nginx/redirection-hosts",
|
||||
params: {
|
||||
|
@@ -1,11 +1,12 @@
|
||||
import * as api from "./base";
|
||||
import type { Setting } from "./models";
|
||||
|
||||
export async function getSetting(id: string, abortController?: AbortController): Promise<Setting> {
|
||||
return await api.get(
|
||||
{
|
||||
url: `/settings/${id}`,
|
||||
export async function getSetting(id: string, expand?: string[], params = {}): Promise<Setting> {
|
||||
return await api.get({
|
||||
url: `/settings/${id}`,
|
||||
params: {
|
||||
expand: expand?.join(","),
|
||||
...params,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -1,11 +1,13 @@
|
||||
import * as api from "./base";
|
||||
import type { HostExpansion } from "./expansions";
|
||||
import type { Stream } from "./models";
|
||||
|
||||
export async function getStream(id: number, abortController?: AbortController): Promise<Stream> {
|
||||
return await api.get(
|
||||
{
|
||||
url: `/nginx/streams/${id}`,
|
||||
export async function getStream(id: number, expand?: HostExpansion[], params = {}): Promise<Stream> {
|
||||
return await api.get({
|
||||
url: `/nginx/streams/${id}`,
|
||||
params: {
|
||||
expand: expand?.join(","),
|
||||
...params,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import * as api from "./base";
|
||||
import type { HostExpansion } from "./expansions";
|
||||
import type { Stream } from "./models";
|
||||
|
||||
export type StreamExpansion = "owner" | "certificate";
|
||||
|
||||
export async function getStreams(expand?: StreamExpansion[], params = {}): Promise<Stream[]> {
|
||||
export async function getStreams(expand?: HostExpansion[], params = {}): Promise<Stream[]> {
|
||||
return await api.get({
|
||||
url: "/nginx/streams",
|
||||
params: {
|
||||
|
@@ -1,19 +1,9 @@
|
||||
import * as api from "./base";
|
||||
import type { TokenResponse } from "./responseTypes";
|
||||
|
||||
interface Options {
|
||||
payload: {
|
||||
identity: string;
|
||||
secret: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function getToken({ payload }: Options, abortController?: AbortController): Promise<TokenResponse> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/tokens",
|
||||
data: payload,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function getToken(identity: string, secret: string): Promise<TokenResponse> {
|
||||
return await api.post({
|
||||
url: "/tokens",
|
||||
data: { identity, secret },
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,14 @@
|
||||
import * as api from "./base";
|
||||
import type { UserExpansion } from "./expansions";
|
||||
import type { User } from "./models";
|
||||
|
||||
export async function getUser(id: number | string = "me", params = {}): Promise<User> {
|
||||
export async function getUser(id: number | string = "me", expand?: UserExpansion[], params = {}): Promise<User> {
|
||||
const userId = id ? id : "me";
|
||||
return await api.get({
|
||||
url: `/users/${userId}`,
|
||||
params,
|
||||
params: {
|
||||
expand: expand?.join(","),
|
||||
...params,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import * as api from "./base";
|
||||
import type { UserExpansion } from "./expansions";
|
||||
import type { User } from "./models";
|
||||
|
||||
export type UserExpansion = "permissions";
|
||||
|
||||
export async function getUsers(expand?: UserExpansion[], params = {}): Promise<User[]> {
|
||||
return await api.get({
|
||||
url: "/users",
|
||||
|
@@ -13,6 +13,7 @@ export * from "./deleteRedirectionHost";
|
||||
export * from "./deleteStream";
|
||||
export * from "./deleteUser";
|
||||
export * from "./downloadCertificate";
|
||||
export * from "./expansions";
|
||||
export * from "./getAccessList";
|
||||
export * from "./getAccessLists";
|
||||
export * from "./getAuditLog";
|
||||
|
@@ -1,11 +1,8 @@
|
||||
import * as api from "./base";
|
||||
import type { TokenResponse } from "./responseTypes";
|
||||
|
||||
export async function refreshToken(abortController?: AbortController): Promise<TokenResponse> {
|
||||
return await api.get(
|
||||
{
|
||||
url: "/tokens",
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function refreshToken(): Promise<TokenResponse> {
|
||||
return await api.get({
|
||||
url: "/tokens",
|
||||
});
|
||||
}
|
||||
|
@@ -1,11 +1,8 @@
|
||||
import * as api from "./base";
|
||||
import type { Certificate } from "./models";
|
||||
|
||||
export async function renewCertificate(id: number, abortController?: AbortController): Promise<Certificate> {
|
||||
return await api.post(
|
||||
{
|
||||
url: `/nginx/certificates/${id}/renew`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function renewCertificate(id: number): Promise<Certificate> {
|
||||
return await api.post({
|
||||
url: `/nginx/certificates/${id}/renew`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,17 +1,10 @@
|
||||
import * as api from "./base";
|
||||
import type { UserPermissions } from "./models";
|
||||
|
||||
export async function setPermissions(
|
||||
userId: number,
|
||||
data: UserPermissions,
|
||||
abortController?: AbortController,
|
||||
): Promise<boolean> {
|
||||
export async function setPermissions(userId: number, data: UserPermissions): Promise<boolean> {
|
||||
// Remove readonly fields
|
||||
return await api.put(
|
||||
{
|
||||
url: `/users/${userId}/permissions`,
|
||||
data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/users/${userId}/permissions`,
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
@@ -1,16 +1,10 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function testHttpCertificate(
|
||||
domains: string[],
|
||||
abortController?: AbortController,
|
||||
): Promise<Record<string, string>> {
|
||||
return await api.get(
|
||||
{
|
||||
url: "/nginx/certificates/test-http",
|
||||
params: {
|
||||
domains: domains.join(","),
|
||||
},
|
||||
export async function testHttpCertificate(domains: string[]): Promise<Record<string, string>> {
|
||||
return await api.get({
|
||||
url: "/nginx/certificates/test-http",
|
||||
params: {
|
||||
domains: domains.join(","),
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@@ -1,14 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function toggleDeadHost(
|
||||
id: number,
|
||||
enabled: boolean,
|
||||
abortController?: AbortController,
|
||||
): Promise<boolean> {
|
||||
return await api.post(
|
||||
{
|
||||
url: `/nginx/dead-hosts/${id}/${enabled ? "enable" : "disable"}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function toggleDeadHost(id: number, enabled: boolean): Promise<boolean> {
|
||||
return await api.post({
|
||||
url: `/nginx/dead-hosts/${id}/${enabled ? "enable" : "disable"}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,14 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function toggleProxyHost(
|
||||
id: number,
|
||||
enabled: boolean,
|
||||
abortController?: AbortController,
|
||||
): Promise<boolean> {
|
||||
return await api.post(
|
||||
{
|
||||
url: `/nginx/proxy-hosts/${id}/${enabled ? "enable" : "disable"}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function toggleProxyHost(id: number, enabled: boolean): Promise<boolean> {
|
||||
return await api.post({
|
||||
url: `/nginx/proxy-hosts/${id}/${enabled ? "enable" : "disable"}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,14 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function toggleRedirectionHost(
|
||||
id: number,
|
||||
enabled: boolean,
|
||||
abortController?: AbortController,
|
||||
): Promise<boolean> {
|
||||
return await api.post(
|
||||
{
|
||||
url: `/nginx/redirection-hosts/${id}/${enabled ? "enable" : "disable"}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function toggleRedirectionHost(id: number, enabled: boolean): Promise<boolean> {
|
||||
return await api.post({
|
||||
url: `/nginx/redirection-hosts/${id}/${enabled ? "enable" : "disable"}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import * as api from "./base";
|
||||
|
||||
export async function toggleStream(id: number, enabled: boolean, abortController?: AbortController): Promise<boolean> {
|
||||
return await api.post(
|
||||
{
|
||||
url: `/nginx/streams/${id}/${enabled ? "enable" : "disable"}`,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
export async function toggleStream(id: number, enabled: boolean): Promise<boolean> {
|
||||
return await api.post({
|
||||
url: `/nginx/streams/${id}/${enabled ? "enable" : "disable"}`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,15 +1,12 @@
|
||||
import * as api from "./base";
|
||||
import type { AccessList } from "./models";
|
||||
|
||||
export async function updateAccessList(item: AccessList, abortController?: AbortController): Promise<AccessList> {
|
||||
export async function updateAccessList(item: AccessList): Promise<AccessList> {
|
||||
// Remove readonly fields
|
||||
const { id, createdOn: _, modifiedOn: __, ...data } = item;
|
||||
|
||||
return await api.put(
|
||||
{
|
||||
url: `/nginx/access-lists/${id}`,
|
||||
data: data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/nginx/access-lists/${id}`,
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
@@ -1,12 +1,7 @@
|
||||
import * as api from "./base";
|
||||
import type { User } from "./models";
|
||||
|
||||
export async function updateAuth(
|
||||
userId: number | "me",
|
||||
newPassword: string,
|
||||
current?: string,
|
||||
abortController?: AbortController,
|
||||
): Promise<User> {
|
||||
export async function updateAuth(userId: number | "me", newPassword: string, current?: string): Promise<User> {
|
||||
const data = {
|
||||
type: "password",
|
||||
current: current,
|
||||
@@ -16,11 +11,8 @@ export async function updateAuth(
|
||||
data.current = current;
|
||||
}
|
||||
|
||||
return await api.put(
|
||||
{
|
||||
url: `/users/${userId}/auth`,
|
||||
data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/users/${userId}/auth`,
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
@@ -1,15 +1,12 @@
|
||||
import * as api from "./base";
|
||||
import type { DeadHost } from "./models";
|
||||
|
||||
export async function updateDeadHost(item: DeadHost, abortController?: AbortController): Promise<DeadHost> {
|
||||
export async function updateDeadHost(item: DeadHost): Promise<DeadHost> {
|
||||
// Remove readonly fields
|
||||
const { id, createdOn: _, modifiedOn: __, ...data } = item;
|
||||
|
||||
return await api.put(
|
||||
{
|
||||
url: `/nginx/dead-hosts/${id}`,
|
||||
data: data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/nginx/dead-hosts/${id}`,
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
@@ -1,15 +1,12 @@
|
||||
import * as api from "./base";
|
||||
import type { ProxyHost } from "./models";
|
||||
|
||||
export async function updateProxyHost(item: ProxyHost, abortController?: AbortController): Promise<ProxyHost> {
|
||||
export async function updateProxyHost(item: ProxyHost): Promise<ProxyHost> {
|
||||
// Remove readonly fields
|
||||
const { id, createdOn: _, modifiedOn: __, ...data } = item;
|
||||
|
||||
return await api.put(
|
||||
{
|
||||
url: `/nginx/proxy-hosts/${id}`,
|
||||
data: data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/nginx/proxy-hosts/${id}`,
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
@@ -1,18 +1,12 @@
|
||||
import * as api from "./base";
|
||||
import type { RedirectionHost } from "./models";
|
||||
|
||||
export async function updateRedirectionHost(
|
||||
item: RedirectionHost,
|
||||
abortController?: AbortController,
|
||||
): Promise<RedirectionHost> {
|
||||
export async function updateRedirectionHost(item: RedirectionHost): Promise<RedirectionHost> {
|
||||
// Remove readonly fields
|
||||
const { id, createdOn: _, modifiedOn: __, ...data } = item;
|
||||
|
||||
return await api.put(
|
||||
{
|
||||
url: `/nginx/redirection-hosts/${id}`,
|
||||
data: data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/nginx/redirection-hosts/${id}`,
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
@@ -1,15 +1,12 @@
|
||||
import * as api from "./base";
|
||||
import type { Setting } from "./models";
|
||||
|
||||
export async function updateSetting(item: Setting, abortController?: AbortController): Promise<Setting> {
|
||||
export async function updateSetting(item: Setting): Promise<Setting> {
|
||||
// Remove readonly fields
|
||||
const { id, ...data } = item;
|
||||
|
||||
return await api.put(
|
||||
{
|
||||
url: `/settings/${id}`,
|
||||
data: data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/settings/${id}`,
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
@@ -1,15 +1,12 @@
|
||||
import * as api from "./base";
|
||||
import type { Stream } from "./models";
|
||||
|
||||
export async function updateStream(item: Stream, abortController?: AbortController): Promise<Stream> {
|
||||
export async function updateStream(item: Stream): Promise<Stream> {
|
||||
// Remove readonly fields
|
||||
const { id, createdOn: _, modifiedOn: __, ...data } = item;
|
||||
|
||||
return await api.put(
|
||||
{
|
||||
url: `/nginx/streams/${id}`,
|
||||
data: data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/nginx/streams/${id}`,
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
@@ -1,15 +1,12 @@
|
||||
import * as api from "./base";
|
||||
import type { User } from "./models";
|
||||
|
||||
export async function updateUser(item: User, abortController?: AbortController): Promise<User> {
|
||||
export async function updateUser(item: User): Promise<User> {
|
||||
// Remove readonly fields
|
||||
const { id, createdOn: _, modifiedOn: __, ...data } = item;
|
||||
|
||||
return await api.put(
|
||||
{
|
||||
url: `/users/${id}`,
|
||||
data: data,
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.put({
|
||||
url: `/users/${id}`,
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
@@ -6,13 +6,9 @@ export async function uploadCertificate(
|
||||
certificate: string,
|
||||
certificateKey: string,
|
||||
intermediateCertificate?: string,
|
||||
abortController?: AbortController,
|
||||
): Promise<Certificate> {
|
||||
return await api.post(
|
||||
{
|
||||
url: `/nginx/certificates/${id}/upload`,
|
||||
data: { certificate, certificateKey, intermediateCertificate },
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.post({
|
||||
url: `/nginx/certificates/${id}/upload`,
|
||||
data: { certificate, certificateKey, intermediateCertificate },
|
||||
});
|
||||
}
|
||||
|
@@ -5,13 +5,9 @@ export async function validateCertificate(
|
||||
certificate: string,
|
||||
certificateKey: string,
|
||||
intermediateCertificate?: string,
|
||||
abortController?: AbortController,
|
||||
): Promise<ValidatedCertificateResponse> {
|
||||
return await api.post(
|
||||
{
|
||||
url: "/nginx/certificates/validate",
|
||||
data: { certificate, certificateKey, intermediateCertificate },
|
||||
},
|
||||
abortController,
|
||||
);
|
||||
return await api.post({
|
||||
url: "/nginx/certificates/validate",
|
||||
data: { certificate, certificateKey, intermediateCertificate },
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user