import type { HttpResources , IBasePath , Logger } from 'src/core/server' ; import { ENTER_SPACE_PATH } from '../../../common' ; import { wrapError } from '../../lib/errors' ; export interface ViewRouteDeps { httpResources : HttpResources ; basePath : IBasePath ; logger : Logger ; } export function initSpacesViewsRoutes ( deps ) { deps . httpResources . register ( { path : '/spaces/space_selector' , validate : false } , ( context , request , response ) => response . renderCoreApp ( ) ) ; deps . httpResources . register ( { path : ENTER_SPACE_PATH , validate : false } , async ( context , request , response ) => { try { const defaultRoute = await context . core . uiSettings . client . get < string > ( 'defaultRoute' ) ; const basePath = deps . basePath . get ( request ) ; const url = `${ basePath }${ defaultRoute }` ; return response . redirected ( { headers : { location : url , } , } ) ; } catch ( e ) { deps . logger . error ( `Error navigating to space: ${ e }` ) ; return response . customError ( wrapError ( e ) ) ; } } ) ; }