File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/val
17
17
import { entities } from '../src/postgres.js' ;
18
18
import { loadConfig } from '../src/config.js' ;
19
19
import type * as misskey from 'misskey-js' ;
20
+ import { ApiError } from "@/server/api/error.js" ;
20
21
21
22
export { server as startServer , jobQueue as startJobQueue } from '@/boot/common.js' ;
22
23
@@ -66,10 +67,13 @@ export const failedApiCall = async <E extends keyof misskey.Endpoints, P extends
66
67
return res . body ;
67
68
} ;
68
69
70
+ type Without < T , U > = { [ P in Exclude < keyof T , keyof U > ] ?: never } ;
71
+ type XOR < T , U > = ( T | U ) extends object ? ( Without < T , U > & U ) | ( Without < U , T > & T ) : T | U ;
72
+
69
73
export const api = async < E extends keyof misskey . Endpoints > ( path : E , params : misskey . Endpoints [ E ] [ 'req' ] , me ?: UserToken ) : Promise < {
70
74
status : number ,
71
75
headers : Headers ,
72
- body : misskey . Endpoints [ E ] [ 'res' ]
76
+ body : XOR < misskey . Endpoints [ E ] [ 'res' ] , { error : ApiError } >
73
77
} > => {
74
78
const bodyAuth : Record < string , string > = { } ;
75
79
const headers : Record < string , string > = {
You can’t perform that action at this time.
0 commit comments