import {IApp, AppData} from "./app"; import {Response, ResponseData} from "../response"; export type DataOf> = ( AppT extends IApp ? DataT : never ); export type ToRequestRouteData = ( { request : { params : { [k : string] : unknown }, query : { [k : string] : unknown }, body : { [k : string] : unknown }, headers : { [k : string] : unknown }, }, response : { locals : DataT["locals"], //The ReturnType is technically incorrect //I would prefer the param to be `never` but it //seems like an `any` arg is not assignable to a `never` param. json : (response : unknown) => Response, } } ); export type ToErrorRouteData = ( { request : { params : { [k : string] : unknown }, query : { [k : string] : unknown }, body : { [k : string] : unknown }, headers : { [k : string] : unknown }, }, response : { locals : Partial, //The ReturnType is technically incorrect //I would prefer the param to be `never` but it //seems like an `any` arg is not assignable to a `never` param. json : (response : unknown) => Response, } } ); export type AssertExpressAppCompatible< DataT extends AppData, ResultT, ErrorT > = ( true extends DataT["__hasParentApp"] ? ["This app is already used as a sub-app and cannot be", ErrorT] : ResultT );