no-explicit-any 등록
This commit is contained in:
@@ -9,17 +9,26 @@ import { type ClassTransformOptions, plainToInstance } from "class-transformer";
|
||||
|
||||
export type APINamespace = {
|
||||
[key: string]: APINamespace
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| ClassType<GET<any, any, any>>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| ClassType<POST<any, any, any>>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| ClassType<PUT<any, any, any>>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| ClassType<DELETE<any, any, any>>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| ClassType<PATCH<any, any, any>>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
| ClassType<HEAD<any, any, any>>
|
||||
;
|
||||
}
|
||||
|
||||
type ValidatorType<T> = T extends undefined ? undefined : ClassType<T>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type AnyAPIExecuter = APIExecuter<any, any, any>;
|
||||
|
||||
export abstract class APIExecuter<R extends ValidResponse, E extends InvalidResponse, Q extends RawArgType>{
|
||||
readonly abstract reqType: HttpMethod;
|
||||
readonly abstract argValidator?: ValidatorType<Q>;
|
||||
@@ -106,6 +115,8 @@ export function raiseError(reason: string, recovery?: recoveryMethod): InvalidRe
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export type ClassType<T> = new (...args: any[]) => T;
|
||||
|
||||
export type APIServerType<T extends Callable> =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
import type { APIExecuter, APINamespace } from './defs.js';
|
||||
import type { AnyAPIExecuter, APINamespace } from './defs.js';
|
||||
|
||||
export function buildAPISystem<N extends APINamespace, Q extends APIExecuter<any, any, any>>(api: N | Q): Router {
|
||||
export function buildAPISystem<N extends APINamespace, Q extends AnyAPIExecuter>(api: N | Q): Router {
|
||||
const router = Router();
|
||||
for (const [key, value] of Object.entries(api)) {
|
||||
if (typeof value === 'function') {
|
||||
|
||||
Reference in New Issue
Block a user