'use strict' ; import { Router , RequestHandler , Request , Response , NextFunction } from 'express' ; import { setupMetaverseAPI , finishMetaverseAPI } from '@Route-Tools/middleware' ; import { buildAccountProfile } from '@Route-Tools/Util' ; import { Accounts } from '@Entities/Accounts' ; import { Availability } from '@Entities/Sets/Availability' ; import { PaginationInfo } from '@Entities/EntityFilters/PaginationInfo' ; import { Logger } from '@Tools/Logging' ; import { GenericFilter } from '@Entities/EntityFilters/GenericFilter' ; const procGetProfiles = async ( req , resp , next ) => { const pager = new PaginationInfo ( ) ; const scoper = new GenericFilter ( { "$or" : [ { "availability" : { "$exists" : false } } , { "availability" : Availability . ALL } , ] } ) ; pager . parametersFromRequest ( req ) ; const accts = [ ] ; for await ( const acct of Accounts . enumerateAsync ( scoper , pager ) ) { accts . push ( await buildAccountProfile ( req , acct ) ) ; } ; req . vRestResp . Data = { profiles : accts } ; scoper . addResponseFields ( req ) ; pager . addResponseFields ( req ) ; next ( ) ; } ; export const name = '/api/v1/profiles' ; export const router = Router ( ) ; router . get ( '/api/v1/profiles' , [ setupMetaverseAPI , procGetProfiles , finishMetaverseAPI ] ) ;