import { Container as container } from '@brainhubeu/hadron-core' ; const getDate = ( ) => { const d = new Date ( ) ; return `${ d . getHours ( ) }:${ d . getMinutes ( ) }:${ d . getSeconds ( ) }` ; } ; export default { routes : { helloWorldRoute : { path : '/' , callback : ( ) => 'Hello world' , methods : [ 'get' ] , } , singleMiddleware : { path : '/singleMiddleware' , callback : ( ) => `Hey! See console` , methods : [ 'get' ] , middleware : [ ( req , res , next ) => { console . log ( `Hello, it's me, the very first middleware!` ) ; next ( ) ; } , ] , } , multipleMiddlewares : { path : '/multipleMiddlewares' , callback : ( ) => `Hey! See console` , methods : [ 'get' ] , middleware : [ ( req , res , next ) => { console . log ( `${ getDate ( ) }> First middleware, jump to next middleware in one second.` ) ; setTimeout ( ( ) => { next ( ) ; } , 1000 ) ; } , ( req , res , next ) => { console . log ( `${ getDate ( ) }> Finally second middleware. One second passed i think !` ) ; next ( ) ; } , ] , } , containerKey : { path : '/getContainerValue' , methods : [ 'get' ] , callback : ( req , { customValue } ) => customValue , } , customContainerKey : { path : '/getContainerValue/:key' , methods : [ 'get' ] , callback : ( req , { key } ) => container . take ( key ) , } , routeWithParam : { path : '/:param' , methods : [ 'get' ] , callback : ( { params } ) => `First route param: ${ params . param }` , } , routeWithMultipleParams : { path : '/:param/:param2' , methods : [ 'get' ] , callback : ( { params } ) => `First param value: ${ params . param }; Second param value: ${ params . param2 }` , } , registerCustomValue : { path : '/:key' , methods : [ 'post' ] , callback : ( { params , body } ) => { container . register ( params . key , body . value ) ; return `Value under key '${ params . key }' is registered` ; } , } , deleteCustomValue : { path : '/:key' , methods : [ 'delete' ] , callback : ( { params } ) => { container . register ( params . key , null ) ; return `Value under key '${ params . key }' has been deleted` ; } , } , } , } ;