Revert "何故かうまく行かないので、とりあえずXORしてみる"

This reverts commit 48cf32c930.
This commit is contained in:
Kisaragi Marine 2024-06-21 05:10:01 +09:00
parent 48cf32c930
commit b3464e0cb7
No known key found for this signature in database
GPG Key ID: C6631564CD2110E4
1 changed files with 1 additions and 5 deletions

View File

@ -17,7 +17,6 @@ import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/val
import { entities } from '../src/postgres.js'; import { entities } from '../src/postgres.js';
import { loadConfig } from '../src/config.js'; import { loadConfig } from '../src/config.js';
import type * as misskey from 'misskey-js'; import type * as misskey from 'misskey-js';
import { ApiError } from "@/server/api/error.js";
export { server as startServer, jobQueue as startJobQueue } from '@/boot/common.js'; export { server as startServer, jobQueue as startJobQueue } from '@/boot/common.js';
@ -67,13 +66,10 @@ export const failedApiCall = async <E extends keyof misskey.Endpoints, P extends
return res.body; return res.body;
}; };
type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
type XOR<T, U> = (T | U) extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
export const api = async <E extends keyof misskey.Endpoints>(path: E, params: misskey.Endpoints[E]['req'], me?: UserToken): Promise<{ export const api = async <E extends keyof misskey.Endpoints>(path: E, params: misskey.Endpoints[E]['req'], me?: UserToken): Promise<{
status: number, status: number,
headers: Headers, headers: Headers,
body: XOR<misskey.Endpoints[E]['res'], { error: ApiError }> body: misskey.Endpoints[E]['res']
}> => { }> => {
const bodyAuth: Record<string, string> = {}; const bodyAuth: Record<string, string> = {};
const headers: Record<string, string> = { const headers: Record<string, string> = {