import { getPermissions } from '../../../lib/permissions' ; import { RouteDependencies } from '../../../types' ; import { addBasePath } from '../../helpers' ; export function registerPermissionsRoute ( { router , lib : { handleEsError } , config : { isSecurityEnabled } , } ) { router . post ( { path : addBasePath ( '/permissions' ) , validate : false } , async ( ctx , req , res ) => { const { client } = ctx . core . elasticsearch ; try { return res . ok ( { body : await getPermissions ( { client , isSecurityEnabled } ) , } ) ; } catch ( error ) { return handleEsError ( { error , response : res } ) ; } } ) ; }