{"id":19778316,"url":"https://github.com/npkgz/koa-session-mysql","last_synced_at":"2026-05-05T13:33:40.324Z","repository":{"id":66170245,"uuid":"124527835","full_name":"npkgz/koa-session-mysql","owner":"npkgz","description":"mysql/mariadb session store for koa-session","archived":false,"fork":false,"pushed_at":"2021-05-24T14:12:24.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-07T21:15:28.460Z","etag":null,"topics":["koa","koa-session","koa2","koajs","mariadb","middleware","mysql","session-storage","session-store"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/koa-session-mysql","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npkgz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-09T10:47:02.000Z","updated_at":"2021-05-24T14:12:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"d9a607c9-642e-4f20-ba49-c04084adadd3","html_url":"https://github.com/npkgz/koa-session-mysql","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/npkgz/koa-session-mysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-session-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-session-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-session-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-session-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npkgz","download_url":"https://codeload.github.com/npkgz/koa-session-mysql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-session-mysql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32651393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["koa","koa-session","koa2","koajs","mariadb","middleware","mysql","session-storage","session-store"],"created_at":"2024-11-12T05:28:53.998Z","updated_at":"2026-05-05T13:33:40.306Z","avatar_url":"https://github.com/npkgz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"koa-session-mysql\n=========================================\n\n\n## Features ##\n\n* Simple mysql based session storage for [koa-session](https://github.com/koajs/session)\n\n## Install ##\n\n```bash\n$ npm install koa-session-mysql --save\n$ yarn add koa-session-mysql\n```\n\n## Usage ##\n\nMySQL Table Layout (required fields)\n\n```sql\nCREATE TABLE IF NOT EXISTS `session` (\n  `session_id` varchar(50) NOT NULL,\n  `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n  `modified` timestamp NULL DEFAULT NULL,\n  `payload` text\n) ENGINE=InnoDB;\n\nALTER TABLE `session` ADD PRIMARY KEY (`session_id`);\n```\n\n## Examples ##\n\n```js\nconst _Koa = require('koa');\nconst _koaSession = require('koa-session');\nconst _mysql = require('mysql-magic');\nconst _koaSessionMysql = require('koa-session-mysql');\n\n// initialize connection pool - koa-session-mysql access it by its name\n// somewhere during your applications bootstrap...initialize a custom pool. \n// It consumes any pool-options of [mysqljs](https://github.com/mysqljs/mysql)\n_mysql.initPool('koa-session', {\n    host     : 'localhost',\n    user     : 'dev',\n    password : 'dev',\n    database : 'koa_test'\n});\n\n// set db pool + table for storage\n_koaSessionMysql.init('koa-session', 'session');\n\n// new Koa app + keygrip keys\nconst _webapp = new _Koa();\n_webapp.keys = ['1234567890'];\n\n// initialize session middleware\ncwebapp.use(_koaSession({\n    store: _koaSessionMysql,\n    key: 'sid',\n    maxAge: 86400000,\n}, _webapp));\n\n_webapp.use(ctx =\u003e {\n    // ignore favicon\n    if (ctx.path === '/favicon.ico') return;\n\n    // increase counter\n    let n = ctx.session.views || 0;\n    ctx.session.views = ++n;\n\n    // show counter\n    ctx.body = n + ' views';\n});\n\n_webapp.listen(3000);\nconsole.log('listening on port 3000');\n```\n\n## License ##\nkoa-session-mysql is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT) - your're welcome to contribute","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Fkoa-session-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpkgz%2Fkoa-session-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Fkoa-session-mysql/lists"}