import * as swaggerUi from 'swagger-ui-express' ; import * as YAML from 'yamljs' ; import * as express from 'express' ; param app export function swaggerify ( exApp , middleware ) { exApp . enable ( 'case sensitive routing' ) ; exApp . enable ( 'strict routing' ) ; exApp . use ( middleware . metadata ( ) ) ; exApp . use ( middleware . files ( exApp , { apiPath : process . env . SWAGGER_API_DOCS_ROOT , rawFilesPath : process . env . SWAGGER_API_DOCS_ROOT , } ) ) ; exApp . use ( middleware . parseRequest ( { cookie : { secret : process . env . SESSION_SECRET } , json : { limit : process . env . REQUEST_LIMIT } } ) ) ; if ( process . env . NODE_ENV === 'production' && process . env . CORS === 'true' ) { exApp . use ( middleware . metadata ( ) ) ; exApp . use ( middleware . CORS ( ) ) ; } exApp . use ( middleware . validateRequest ( ) ) ; const swaggerDocument = YAML . load ( './server/common/swagger/Api.yaml' ) ; exApp . use ( '/swagger' , swaggerUi . serve , swaggerUi . setup ( swaggerDocument ) ) ; } ;