koa-session-mysql
Features
- Simple mysql based session storage for koa-session
Install
$ npm install koa-session-mysql --save$ yarn add koa-session-mysql
Usage
MySQL Table Layout (required fields)
NOT EXISTS `session` ( `session_id` varchar(50) NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `modified` timestamp NULL DEFAULT NULL, `payload` text) ENGINE=InnoDB; `session` ADD PRIMARY KEY (`session_id`);
Examples
const _Koa = ;const _koaSession = ;const _mysql = ;const _koaSessionMysql = ; // initialize connection pool - koa-session-mysql access it by its name// somewhere during your applications bootstrap...initialize a custom pool. // It consumes any pool-options of [mysqljs](https://github.com/mysqljs/mysql)_mysql; // set db pool + table for storage_koaSessionMysql; // new Koa app + keygrip keysconst _webapp = ;_webappkeys = '1234567890'; // initialize session middlewarecwebapp; _webapp; _webapp;console;
License
koa-session-mysql is OpenSource and licensed under the Terms of The MIT License (X11) - your're welcome to contribute