'use strict' ; import { Router , RequestHandler , Request , Response , NextFunction } from 'express' ; import { setupMetaverseAPI , finishMetaverseAPI } from '@Route-Tools/middleware' ; import { accountFromAuthToken , accountFromParams } from '@Route-Tools/middleware' ; import { Perm } from '@Route-Tools/Perm' ; import { checkAccessToEntity } from '@Route-Tools/Permissions' ; import { buildAccountProfile } from '@Route-Tools/Util' ; import { Accounts } from '@Entities/Accounts' ; import { VKeyedCollection } from '@Tools/vTypes' ; import { Logger } from '@Tools/Logging' ; const procGetProfileAccountId = async ( req , resp , next ) => { if ( req . vAccount ) { if ( await checkAccessToEntity ( req . vAuthToken , req . vAccount , [ Perm . PUBLIC , Perm . OWNER , Perm . ADMIN ] ) ) { req . vRestResp . Data = { account : await buildAccountProfile ( req , req . vAccount ) } ; } else { req . vRestResp . respondFailure ( 'Unauthorized' ) ; } ; } else { req . vRestResp . respondFailure ( 'Target account not found' ) ; } ; next ( ) ; } ; export const name = '/api/v1/profile/:accountId' ; export const router = Router ( ) ; router . get ( '/api/v1/profile/:accountId' , [ setupMetaverseAPI , accountFromParams , procGetProfileAccountId , finishMetaverseAPI ] ) ;