'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 { AccountScopeFilter } from '@Entities/EntityFilters/AccountScopeFilter' ; import { PaginationInfo } from '@Entities/EntityFilters/PaginationInfo' ; import { GenericFilter } from '@Entities/EntityFilters/GenericFilter' ; import { Logger } from '@Tools/Logging' ; import { Tokens } from '@Entities/Tokens' ; import { AuthToken } from '@Entities/AuthToken' ; const procGetAccountTokens = async ( req , resp , next ) => { if ( req . vRestResp && req . vAuthAccount && req . vAccount ) { const pager = new PaginationInfo ( ) ; const scoper = new AccountScopeFilter ( req . vAuthAccount , 'accountId' ) ; pager . parametersFromRequest ( req ) ; scoper . parametersFromRequest ( req ) ; const acctFilter = new GenericFilter ( { 'accountId' : req . vAccount . id } ) ; const toks = [ ] ; for await ( const tok of Tokens . enumerateAsync ( acctFilter , pager , scoper ) ) { toks . push ( tok ) ; } ; req . vRestResp . Data = { 'tokens' : toks } ; pager . addResponseFields ( req ) ; } ; next ( ) ; } ; export const name = '/api/v1/account/:accountId/tokens' ; export const router = Router ( ) ; router . get ( '/api/v1/account/:accountId/tokens' , [ setupMetaverseAPI , accountFromAuthToken , accountFromParams , procGetAccountTokens , finishMetaverseAPI ] ) ;