mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
add number typeof (#146)
* fix * fix * update version * fix helpers * fix * update version * add number typeof * accept auth option
This commit is contained in:
parent
20dc37d9e3
commit
03bd41caea
@ -59,6 +59,7 @@ export function toSnakeCase<Obj extends Record<string, any>>(target: Obj): Objec
|
|||||||
case "bigint":
|
case "bigint":
|
||||||
case "boolean":
|
case "boolean":
|
||||||
case "function":
|
case "function":
|
||||||
|
case "number":
|
||||||
case "symbol":
|
case "symbol":
|
||||||
case "undefined":
|
case "undefined":
|
||||||
result[ReplaceRegex.snake(key)] = value;
|
result[ReplaceRegex.snake(key)] = value;
|
||||||
@ -97,6 +98,7 @@ export function toCamelCase<Obj extends Record<string, any>>(target: Obj): Objec
|
|||||||
case "boolean":
|
case "boolean":
|
||||||
case "function":
|
case "function":
|
||||||
case "symbol":
|
case "symbol":
|
||||||
|
case "number":
|
||||||
case "undefined":
|
case "undefined":
|
||||||
result[ReplaceRegex.camel(key)] = value;
|
result[ReplaceRegex.camel(key)] = value;
|
||||||
break;
|
break;
|
||||||
|
@ -2,6 +2,7 @@ import type { RawFile, RequestData } from '@discordjs/rest';
|
|||||||
import { REST } from '@discordjs/rest';
|
import { REST } from '@discordjs/rest';
|
||||||
import type { Identify } from '@biscuitland/common';
|
import type { Identify } from '@biscuitland/common';
|
||||||
import type { RequestMethod } from './Router';
|
import type { RequestMethod } from './Router';
|
||||||
|
import { Routes } from './Routes';
|
||||||
export class BiscuitREST {
|
export class BiscuitREST {
|
||||||
api: REST;
|
api: REST;
|
||||||
constructor(public options: BiscuitRESTOptions) {
|
constructor(public options: BiscuitRESTOptions) {
|
||||||
@ -63,7 +64,7 @@ export class BiscuitREST {
|
|||||||
|
|
||||||
export type BiscuitRESTOptions = Identify<ConstructorParameters<typeof REST>[0] & { token: string }>;
|
export type BiscuitRESTOptions = Identify<ConstructorParameters<typeof REST>[0] & { token: string }>;
|
||||||
|
|
||||||
export type RequestOptions = Pick<RequestData, 'passThroughBody' | 'reason'>;
|
export type RequestOptions = Pick<RequestData, 'passThroughBody' | 'reason' | 'auth'>;
|
||||||
|
|
||||||
export type RequestObject<M extends RequestMethod, B = Record<string, any>, Q = Record<string, any>> = {
|
export type RequestObject<M extends RequestMethod, B = Record<string, any>, Q = Record<string, any>> = {
|
||||||
query?: Q;
|
query?: Q;
|
||||||
@ -71,12 +72,12 @@ export type RequestObject<M extends RequestMethod, B = Record<string, any>, Q =
|
|||||||
(M extends `${RequestMethod.Get}`
|
(M extends `${RequestMethod.Get}`
|
||||||
? unknown
|
? unknown
|
||||||
: {
|
: {
|
||||||
body?: B;
|
body?: B;
|
||||||
files?: RawFile[];
|
files?: RawFile[];
|
||||||
});
|
});
|
||||||
|
|
||||||
export type RestArguments<M extends RequestMethod, B = any, Q extends never | Record<string, any> = any> = M extends RequestMethod.Get
|
export type RestArguments<M extends RequestMethod, B = any, Q extends never | Record<string, any> = any> = M extends RequestMethod.Get
|
||||||
? Q extends never
|
? Q extends never
|
||||||
? RequestObject<M, never, B>
|
? RequestObject<M, never, B>
|
||||||
: never
|
: never
|
||||||
: RequestObject<M, B, Q>;
|
: RequestObject<M, B, Q>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user