Data Layer medium complexity backend
0
Dependencies
1
Dependents
1
Entities
0
Integrations

Description

Data access layer for the sessions table supporting full session lifecycle management. Handles both mobile JWT refresh token records and admin portal cookie-backed session rows, with revocation status tracking and expired-record cleanup.

Feature: Session Management

sessions-repository

Responsibilities

  • Query active sessions by organization ID or user ID
  • Create session records on login and update last-activity timestamps
  • Mark sessions as revoked on remote termination or logout
  • Look up sessions by refresh token hash for revocation checks
  • Delete or archive expired session records

Interfaces

findActiveByOrganization(organizationId: string): Promise<Session[]>
findByUser(userId: string): Promise<Session[]>
findById(sessionId: string): Promise<Session | null>
findByRefreshTokenHash(hash: string): Promise<Session | null>
create(data: CreateSessionDto): Promise<Session>
revoke(sessionId: string): Promise<void>
revokeAllForUser(userId: string): Promise<void>
deleteExpired(): Promise<number>

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component