import * as path from "path" ; import { Response } from "express" ; import nconf from "nconf" ; /**
 * Helper function to handle a promise that should be returned to the user
 */ export function handleResponse < T > ( resultP , response , cache = true , status = 200 , handler = ( value ) => value ) { resultP . then ( handler ) . then ( ( result ) => { if ( cache ) { response . setHeader ( "Cache-Control" , "public, max-age=31536000" ) ; } response . status ( status ) . json ( result ) ; } , ( error ) => { response . status ( 400 ) . json ( error ) ; } ) ; } export function getGitDir ( store , tenantId ) { const directory = store . get ( "storage" ) ; return path . join ( directory , `./${ tenantId }` ) ; }