This commit is contained in:
IDONTSUDO 2023-11-20 00:48:40 +03:00
parent d70253d6a6
commit fa645dde92
51 changed files with 657 additions and 281 deletions

View file

@ -13,14 +13,19 @@ type Method =
| "options"
| "head";
export type CallbackStrategyWithValidationModel<T> = (
a: T
) => Promise<Result<any, any>>;
// TODO(IDOTSUDO):NEED IMPLEMENTS
// interface ISubSetFeatureRouter<T>{
// method:Method,
// fn:CallbackStrategyWithValidationModel<T>
// }
export type ResponseBase = Promise<Result<any, any>>;
// TODO(IDONTSUDO): rewrite the router for the strategy
export type CallbackStrategyWithEmpty = () => ResponseBase;
export type CallbackStrategyWithValidationModel<T> = (a: T) => ResponseBase;
export type CallbackStrategyWithIdQuery = (id: string) => ResponseBase;
export type CallBackStrategyWithQueryPage = (page: string) => ResponseBase;
export type CallbackStrategyWithFileUpload = (file: File) => ResponseBase;
interface ISubSetFeatureRouter<T> {
method: Method;
fn: CallbackStrategyWithValidationModel<T>;
}
abstract class ICoreHttpController {
abstract mainURL: string;
@ -31,6 +36,7 @@ abstract class ICoreHttpController {
export class CoreHttpController<V> implements ICoreHttpController {
mainURL: string;
validationModel: any;
subRoutes: ISubSetFeatureRouter<any>[] = [];
routes = {
POST: null,
@ -47,6 +53,11 @@ export class CoreHttpController<V> implements ICoreHttpController {
}
call(): Routes {
if (this.subRoutes.isNotEmpty()) {
this.subRoutes.map((el) => {
console.log(this.router[el.method]);
});
}
if (this.routes["POST"] != null) {
this.router.post(
this.mainURL,