import { canStartTrial , startTrial } from '../../../lib/start_trial' ; import { RouteDependencies } from '../../../types' ; import { addBasePath } from '../../helpers' ; export function registerStartTrialRoutes ( { router , lib : { handleEsError } , plugins : { licensing } , } ) { router . get ( { path : addBasePath ( '/start_trial' ) , validate : false } , async ( ctx , req , res ) => { const { client } = ctx . core . elasticsearch ; try { return res . ok ( { body : await canStartTrial ( client ) } ) ; } catch ( error ) { return handleEsError ( { error , response : res } ) ; } } ) ; router . post ( { path : addBasePath ( '/start_trial' ) , validate : false } , async ( ctx , req , res ) => { const { client } = ctx . core . elasticsearch ; try { return res . ok ( { body : await startTrial ( { client , licensing } ) , } ) ; } catch ( error ) { return handleEsError ( { error , response : res } ) ; } } ) ; }