A Koa2 session middleware backed by MySQL, designed for TypeScript projects. Version 3.1.9 provides session management with automatic garbage collection, custom expiry, and typed session data via generics. Unlike generic session stores, it integrates directly with Sequelize ORM and supports both auto and manual GC modes. The library is suitable for Koa2 applications requiring persistent sessions with MySQL storage, and is actively maintained with a focus on TypeScript support.
npm install maranda-koa2-session-mysqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Setup Koa2 with MySQL session store, define typed session data, and use middware with garbage collection options.
Use Session.middware (not Session.middleware) in your code.
Use import syntax: import Session from 'maranda-koa2-session-mysql'.
Set session data before calling next(), or use manual save with ctx.session.save() after next and handle cookies yourself.
Ensure no table named 'sessions' exists in your MySQL database, or specify a custom tableName in options.
Run 'npm install maranda-koa2-session-mysql' and verify import: import Session from 'maranda-koa2-session-mysql'.
Remove manual save calls; session data is automatically saved after the response unless using manual mode. For manual GC, set gcType: 'manual' and call session.save() after modification.