2025-08-22 16:25:06 +02:00

40 lines
1.4 KiB
Markdown

# InMemory Sessions
A Service to store Sessions in Memory.
## Install
```bash
npm i --save @apihub24/in-memory-sessions
```
## Dependencies
| Exported Injection Keys |
| ------------------------- |
| @apihub24/session_service |
## Usage
```typescript
// NestJs usage
import { InMemorySessionsModule } from "@apihub24/in-memory-sessions";
@Module({
imports: [InMemorySessionsModule.forRoot()]
})
...
// Other usage
import { InMemorySessionsModule } from "@apihub24/in-memory-sessions";
const sessionService = new InMemorySessionService();
```
| Function | Description |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------- |
| create(account: IAccount): Promise<ISession> | Create a new Session from a IAccount and returns it |
| getBy(filter: (account: IAccount) => boolean): Promise<ISession[]> | get a ISession by a IAccount filter |
| getById(sessionId: string): Promise<ISession> | get a ISession by a session id. the returned ISession can be null if not exists |
| remove(sessionId: string): Promise<void> | remove the ISession by a session id. |