'use strict' ; import { Router , RequestHandler , Request , Response , NextFunction } from 'express' ; import { setupMetaverseAPI , finishMetaverseAPI } from '@Route-Tools/middleware' ; import { accountFromAuthToken } from '@Route-Tools/middleware' ; import { updateLocationInfo } from '@Route-Tools/Util' ; import { Accounts } from '@Entities/Accounts' ; import { IsNotNullOrEmpty } from '@Tools/Misc' ; import { Logger } from '@Tools/Logging' ; const procPutUserHeartbeat = async ( req , resp , next ) => { if ( req . vAuthAccount ) { const updates = await updateLocationInfo ( req ) ; if ( IsNotNullOrEmpty ( updates ) ) { updates . timeOfLastHeartbeat = new Date ( ) ; await Accounts . updateEntityFields ( req . vAuthAccount , updates ) ; if ( IsNotNullOrEmpty ( req . vAuthAccount . locationNodeId ) ) { req . vRestResp . Data = { 'session_id' : req . vAuthAccount . locationNodeId } ; } ; } ; } else { req . vRestResp . respondFailure ( req . vAccountError ?? 'Not logged in' ) ; } ; next ( ) ; } ; export const name = '/api/v1/user/heartbeat' ; export const router = Router ( ) ; router . put ( '/api/v1/user/heartbeat' , [ setupMetaverseAPI , accountFromAuthToken , procPutUserHeartbeat , finishMetaverseAPI ] ) ;