'use strict' ; import { Router , RequestHandler , Request , Response , NextFunction } from 'express' ; import { setupMetaverseAPI , finishMetaverseAPI , finishReturnData } from '@Route-Tools/middleware' ; import { Config , readInJSON } from '@Base/config' ; import { Logger } from '@Tools/Logging' ; import { IsNotNullOrEmpty } from '@Tools/Misc' ; import deepmerge from 'deepmerge' ; const procMetaverseInfo = async ( req , resp , next ) => { let data = { 'metaverse_name' : Config . metaverse [ "metaverse-name" ] , 'metaverse_nick_name' : Config . metaverse [ "metaverse-nick-name" ] , 'metaverse_url' : Config . metaverse [ "metaverse-server-url" ] , 'ice_server_url' : Config . metaverse [ "default-ice-server-url" ] , 'metaverse_server_version' : Config . server [ "server-version" ] , } ; const additionUrl = Config [ "metaverse-server" ] [ "metaverse-info-addition-file" ] ; try { if ( IsNotNullOrEmpty ( additionUrl ) ) { const additional = await readInJSON ( additionUrl ) ; if ( IsNotNullOrEmpty ( additional ) ) { data = deepmerge ( data , additional ) ; } ; } ; } catch ( err ) { Logger . error ( `procMetaverseInfo: exception reading additional info file: ${ err }` ) ; } ; req . vRestResp . Data = data ; next ( ) ; } ; export const name = "/api/v1/metaverse_info" ; export const router = Router ( ) ; router . get ( '/api/metaverse_info' , [ setupMetaverseAPI , procMetaverseInfo , finishReturnData ] ) ; router . get ( '/api/v1/metaverse_info' , [ setupMetaverseAPI , procMetaverseInfo , finishReturnData ] ) ;