'use strict' ; import { Config } from '@Base/config' ; import { Router , RequestHandler , Request , Response , NextFunction } from 'express' ; import { setupMetaverseAPI , finishMetaverseAPI , usernameFromParams } from '@Route-Tools/middleware' ; import { HTTPStatusCode } from '@Route-Tools/RESTResponse' ; const procGetUserProfile = async ( req , resp , next ) => { if ( req . vUsername && typeof ( req . vUsername ) === 'string' ) { const dashboardURL = Config . metaverse [ "dashboard-url" ] ; const metaverseURL = encodeURIComponent ( Config . metaverse [ "metaverse-server-url" ] ) ; const username = encodeURIComponent ( req . vUsername ) ; const redirectionURL = `${ dashboardURL }?metaverse=${ metaverseURL }&page=profile/${ username }` ; resp . statusCode = HTTPStatusCode . Found ; resp . setHeader ( 'Location' , redirectionURL ) , resp . setHeader ( 'content-type' , 'text/html' ) ; resp . send ( ) ; } else { req . vRestResp . respondFailure ( 'usename not specified' ) ; } next ( ) ; } ; export const name = '/users/:username' ; export const router = Router ( ) ; router . get ( '/users/:username' , [ setupMetaverseAPI , usernameFromParams , procGetUserProfile , finishMetaverseAPI ] ) ;