Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 64x 159x 159x 3x 5x 1x 7x 1x 9x 64x | import { IUnleashStores } from '../types/stores';
import { IUnleashConfig } from '../types/option';
import { Logger } from '../logger';
import { ISession, ISessionStore } from '../types/stores/session-store';
export default class SessionService {
private logger: Logger;
private sessionStore: ISessionStore;
constructor(
{ sessionStore }: Pick<IUnleashStores, 'sessionStore'>,
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
) {
this.logger = getLogger('lib/services/session-service.ts');
this.sessionStore = sessionStore;
}
async getActiveSessions(): Promise<ISession[]> {
return this.sessionStore.getActiveSessions();
}
async getSessionsForUser(userId: number): Promise<ISession[]> {
return this.sessionStore.getSessionsForUser(userId);
}
async getSession(sid: string): Promise<ISession> {
return this.sessionStore.get(sid);
}
async deleteSessionsForUser(userId: number): Promise<void> {
return this.sessionStore.deleteSessionsForUser(userId);
}
async deleteSession(sid: string): Promise<void> {
return this.sessionStore.delete(sid);
}
async insertSession({
sid,
sess,
}: Pick<ISession, 'sid' | 'sess'>): Promise<ISession> {
return this.sessionStore.insertSession({ sid, sess });
}
}
module.exports = SessionService;
|