import express from 'express' ; import Logger from '../../loaders/logger' ; import { getInstances } from '../../helpers' ; import { IInstances } from '../../types' ; const api = express . Router ( ) ; const DEFAULT_ERROR_MESSAGE = "Error while processing request" ; const defaultMiddlewares = [ express . json ( ) , express . urlencoded ( { extended : true } ) ] ; export default ( app ) => { app . use ( '/api' , api ) ; /**
     * Endpoint for getting info about the available features
     */ api . get ( '/instances' , defaultMiddlewares , async ( req , res ) => { Logger . info ( "Received request on /api/instances" ) ; try { const instancesObject = await getInstances ( ) ; res . send ( instancesObject . instances ) ; } catch ( error ) { Logger . error ( 'Error in GET /api/instances' ) ; res . status ( 400 ) . send ( DEFAULT_ERROR_MESSAGE ) ; } } ) ; } ;