refactor(backend): encapsulate any affection in ApiCallService.ts

This commit is contained in:
Kisaragi 2024-03-09 03:40:35 +09:00 committed by GitHub
parent 27f823e882
commit 4711e1a33f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -220,11 +220,18 @@ export class ApiCallService implements OnApplicationShutdown {
}
@bindThis
private async call(
ep: IEndpoint & { exec: any },
private async call<Data>(
ep: IEndpoint & { exec: (
data: Data,
user: MiLocalUser,
token: MiAccessToken | null | undefined,
file: { name: string, path: string } | null,
ip: any,
headers: any
) => Promise<any> },
user: MiLocalUser | null | undefined,
token: MiAccessToken | null | undefined,
data: any,
data: Data,
file: {
name: string;
path: string;
@ -362,7 +369,7 @@ export class ApiCallService implements OnApplicationShutdown {
}
// API invoking
return await ep.exec(data, user, token, file, request.ip, request.headers).catch((err: Error) => {
return await ep.exec(data, user, token, file, request.ip, request.headers).catch((err) => {
if (err instanceof ApiError || err instanceof AuthenticationError) {
throw err;
} else {