'use strict' ; import { Router , RequestHandler , Request , Response , NextFunction } from 'express' ; import { setupMetaverseAPI , finishMetaverseAPI } from '@Route-Tools/middleware' ; import { accountFromAuthToken } from '@Route-Tools/middleware' ; import { param1FromParams , param2FromParams , param3FromParams } from '@Route-Tools/middleware' ; import { GenericFilter } from '@Entities/EntityFilters/GenericFilter' ; import { getObject } from '@Tools/Db' ; import { Accounts } from '@Entities/Accounts' ; import { SimpleObject } from '@Tools/Misc' ; import { Logger } from '@Tools/Logging' ; const procMaintRaw = async ( req , resp , next ) => { if ( req . vRestResp && req . vAuthAccount ) { if ( Accounts . isAdmin ( req . vAuthAccount ) ) { if ( req . vParam1 && req . vParam2 && req . vParam3 ) { const collection = req . vParam1 ; const field = req . vParam2 ; const value = req . vParam3 ; const criteria = new GenericFilter ( SimpleObject ( field , value ) ) ; req . vRestResp . Data = await getObject ( collection , criteria ) ; } else { req . vRestResp . respondFailure ( 'parameters missing' ) ; } ; } else { req . vRestResp . respondFailure ( 'not admin' ) ; } ; } ; next ( ) ; } ; export const name = '/api/maint/raw/' ; export const router = Router ( ) ; router . get ( '/api/maint/raw/:param1/:param2/:param3' , [ setupMetaverseAPI , accountFromAuthToken , param1FromParams , param2FromParams , param3FromParams , procMaintRaw , finishMetaverseAPI ] ) ;