{"id":18579212,"url":"https://github.com/faust64/somesession","last_synced_at":"2025-06-28T17:35:40.984Z","repository":{"id":57146915,"uuid":"116868115","full_name":"faust64/somesession","owner":"faust64","description":"Express.js sessions store abstraction library","archived":false,"fork":false,"pushed_at":"2020-11-03T06:41:32.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T23:33:02.603Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/faust64.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-09T20:37:53.000Z","updated_at":"2018-06-13T20:08:42.000Z","dependencies_parsed_at":"2022-08-29T20:51:26.629Z","dependency_job_id":null,"html_url":"https://github.com/faust64/somesession","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faust64%2Fsomesession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faust64%2Fsomesession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faust64%2Fsomesession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faust64%2Fsomesession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faust64","download_url":"https://codeload.github.com/faust64/somesession/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254455604,"owners_count":22074015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-06T23:39:30.178Z","updated_at":"2025-05-16T02:30:23.133Z","avatar_url":"https://github.com/faust64.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express.js Sessions Store Abstraction Library\n\n * Last tests against master on CircleCI: [![CircleCI](https://circleci.com/gh/faust64/somesession.svg?style=svg)](https://circleci.com/gh/faust64/somesession)\n\n * Install with: `npm install somesession`\n\n * Beware `somesession` would only pull all its depdencies if installed with its `devDependencies`.\n\nConsidering production deployments, you would have to pick from these `devDependencies`, those you would actually rely on.\nInclude them from whatever parent project or other piece of code you'ld be loading `somesession` from.\n\n * Write backend-agnostic code:\n\n```\n// cassandra\nconst storeOptions = { driver: 'cassandra', database: 'sessions', username: 'casuser', password: 'caspass', host: '3.4.5.6', table: 'sessions' };\n// mysql\nconst storeOptions = ({ driver: 'mysql', database: 'sessions', username: 'myuser', password: 'mypass', host: '2.3.4.5', table: 'sessions' };\n// postgres\nconst storeOptions = ({ driver: 'postgres', database: 'sessions', username: 'pguser', password: 'pgpass', host: '1.2.3.4', table: 'sessions' };\n// redis\nconst storeOptions = ({ driver: 'redis', database: 0, password: 'redisauthpass', host: '4.5.6.7' };\n// defaults to sqlite\nconst storeOptions = ({ database: 'sessions.sqlite', path: './', table: 'sessions' };\n\nconst bodyParser = require('body-parser');\nconst express = require('express');\nconst http = require('http');\nconst session = require('express-session');\nconst store = require('somesession');\n\nconst app = express();\napp.use(bodyParser.json());\napp.use(bodyParser.urlencoded({ extended: true }));\n\nconst storage = store(storeOptions, session);\napp.use(session({\n\tcookie: { secure: process.env.NODE_ENV === 'production' },\n\tstore: storage, secret: 'secr3t',\n\tresave: false, saveUninitialized: false,\n\tcookie: { maxAge: 86400 }\n    });\n\nconst httpServer = http.createServer(app);\n\napp.get('/', (req, res) =\u003e {\n\tif (req.session !== undefined \u0026\u0026 req.session.userid !== undefined \u0026\u0026 req.session.userid !== false) {\n\t    res.send(req.session.userid);\n\t} else { res.send('unauthenticated'); }\n    });\n\napp.post('/login', (req, res) =\u003e {\n\tlet userId = req.body.userId || false;\n\tif (userId !== false) { req.session.userid = userId; }\n\tres.redirect('/');\n    });\n\napp.post('/logout', (req, res) =\u003e {\n\tif (req.session !== undefined \u0026\u0026 req.session.userid !== undefined \u0026\u0026 req.session.userid !== false) {\n\t    req.session.userid = false;\n\t    req.session.destroy();\n\t    delete req.session;\n\t}\n\tres.redirect('/');\n    });\n\nport = port || 8080;\nhttpServer.listen(port, '127.0.0.1', (err, res) =\u003e {\n\tif (err) { reject(err); }\n\tconsole.log(`mock server listening on 127.0.0.1:${port}`);\n\tresolve(httpServer);\n    });\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaust64%2Fsomesession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaust64%2Fsomesession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaust64%2Fsomesession/lists"}