import config from './../../config' ; import { SessionData , Store } from 'express-session' ; export class AdminService { private store : Store = config . sessionConfig . store as Store ; getActiveSessions ( ) { return new Promise ( ( resolve , reject ) => { this . store . all ? ( ( err , sessions ) => { if ( err ) { return reject ( err ) ; } if ( sessions ) { const result = Object . entries ( sessions ) . map ( ( [ sessionId , session ] ) => { return { sessionId , user : { email : session . user ?. email , role : session . user ?. role } } ; } ) ; resolve ( result ) ; } } ) : [ ] ; } ) ; } destroySession ( sessionId ) { return new Promise ( ( resolve , reject ) => { this . store . destroy ( sessionId , ( error ) => { error ? reject ( error ) : resolve ( ) ; } ) ; } ) ; } }