import express from "express" ; import sinon from "sinon" ; import { IBaseRequest , managementApiAdapter , staticServerAdapter , } from "../src" ; interface IExecMocks { [ usecase ] : sinon . SinonStub ; } export function getManagementApiAdapter ( execMocks ) { return getServer ( execMocks , managementApiAdapter ( { serviceName : "serviceName" , serviceVersion : "serviceVersion" , serviceHost : "serviceHost" , serviceBasePath : "/" , maxRequestBodySize : "100mb" , } ) , "/" ) ; } export function getStaticServerAdapterServer ( execMocks , options ? ) { return getServer ( execMocks , staticServerAdapter ( options || { } ) , options && options . mountPath ) ; } function getServer ( execMocks , app , mountPath = "/" ) { return express ( ) . use ( ( req , _res , next ) => { req . makeUsecase = ( name ) => ( { exec : execMocks [ name ] } as any ) ; next ( ) ; } ) . use ( mountPath , app ) ; }