{"_id":"mongo-express-session-store","_rev":"29-e00a99efcac5840b80ab582fbea279b1","name":"mongo-express-session-store","dist-tags":{"latest":"1.0.16"},"versions":{"1.0.15":{"name":"mongo-express-session-store","version":"1.0.15","repository":{"type":"git","url":"git+https://github.com/Reiner1210/mongo-express-session-store.git"},"homepage":"https://github.com/Reiner1210/mongo-express-session-store","description":"Middleware to store expression session data in mongoDB Database. Using the official mogoDB driver, less dependencies and possibility to reuse the client / database for other database tasks.","main":"index.js","scripts":{"test":"jest"},"keywords":["mongodb","express","session","ES6"],"author":{"name":"Reiner Pröls"},"license":"ISC","dependencies":{"express-session":"^1.17.3","mongodb":"^5.1.0"},"devDependencies":{"dotenv":"^16.0.3","jest":"^29.4.3"},"gitHead":"50c7fdda1a628ef87e9de999858708fe50cbe836","bugs":{"url":"https://github.com/Reiner1210/mongo-express-session-store/issues"},"_id":"mongo-express-session-store@1.0.15","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"integrity":"sha512-m6MBh9npo0HO3hSxtbDIqDIlMiU/0Uj2wQLfLoCmsvDXFixxWrjy7+8icHXeaRMV/YzAlxZvIk5n/7NM3xeOiw==","shasum":"8d77f016a9545fefe33abea0cef93f6a9f59fabf","tarball":"https://registry.npmjs.org/mongo-express-session-store/-/mongo-express-session-store-1.0.15.tgz","fileCount":4,"unpackedSize":21896,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCbnrKfmP8Xli0apx95QEZbw1CQkBFhzZQdKksvA6mUYQIhAKKt1RbAMLoJgEuniJCgd/4JbtgsC3+WAX2DJA5G+zJV"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+gXyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo4XBAAiLgx50vzH2BXgJAhJ8sUi+5XmgVvsYrYVlmiBWJu4bQiEFRh\r\ngq4Jjlx3i/RQ9MOCHdrgY38CVXLtP1antGgrVDryBmljCIc6qC7dZ3GcTyBd\r\n9C171Txh2j83bbWNc27iBdX9x18qwtCaI47QEh1ze0HIOlmWb+IpAlf1xuk/\r\nU2VBxWA9ub11bmEvu4CbNCCI/RLD4YrKOwjdWA0+ViQFzw4HCAaXgMbWmzsU\r\ntpemzCJFm9J9PwDnqwJ36cgYSA4r7Oxyr82/QVoGGaBjlglsARCsSrBB6Op5\r\n/+H3BxI00Z6xtHKjWWS5w+p5/3CEBefMtQgaSM6MQt8zIZnuU7gNGUd2g6hW\r\njQViXZwNiying9NqJr8aQj8OZqvFa02zwWfCmeZ0/oQqjmqncxXdeY38FqnQ\r\n9JeDuo5bBwD4yzxwJg2/k5g4lYKmpk2fnu5yEdzc1Q3JIjX2qbyO15A8TPtg\r\nBUabR6mRqlqQiLNdA6r3wQ312t5s7GOdbwS7gmA3w8v6iybmkjbPGMqVMfiP\r\nJYo5x2gQFHu/pHMPklDOs1RAF6HWv1A5j9Dzdk20z7bQtwU29mSNxV4Gs+4G\r\nnzyP4P2BaFTkbpghjoPH++EbLPWombGUz+CUqCvLccgNv2EYZQmohiPbB2hX\r\nDEGOym/sHHyCiVjnRr6jcj2cpSrwoM3ZEjY=\r\n=52C9\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"reiner1210","email":"Reiner.Proels@gmail.com"},"directories":{},"maintainers":[{"name":"reiner1210","email":"Reiner.Proels@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mongo-express-session-store_1.0.15_1677329905869_0.7734857048563362"},"_hasShrinkwrap":false},"1.0.16":{"name":"mongo-express-session-store","version":"1.0.16","repository":{"type":"git","url":"git+https://github.com/Reiner1210/mongo-express-session-store.git"},"homepage":"https://github.com/Reiner1210/mongo-express-session-store","description":"Middleware to store expression session data in mongoDB Database. Using the official mogoDB driver, less dependencies and possibility to reuse the client / database for other database tasks.","main":"index.js","scripts":{"test":"jest"},"keywords":["mongodb","express","session","ES6"],"author":{"name":"Reiner Pröls","email":"Reiner.Proels@gmail.com"},"license":"ISC","dependencies":{"express-session":"^1.17.3","mongodb":"^5.1.0"},"devDependencies":{"dotenv":"^16.0.3","jest":"^29.4.3"},"gitHead":"50c7fdda1a628ef87e9de999858708fe50cbe836","bugs":{"url":"https://github.com/Reiner1210/mongo-express-session-store/issues"},"_id":"mongo-express-session-store@1.0.16","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"integrity":"sha512-CIzPtX9+R/xCZ3I8ClPODeWDfh6r1L+aODcstgKzAasHYqMRToEOlQom3sM4d9Q5v0qH+HL1fPkqv8WtdnGg4w==","shasum":"ebbd247331aab50b596de0747ea4118d890d6b15","tarball":"https://registry.npmjs.org/mongo-express-session-store/-/mongo-express-session-store-1.0.16.tgz","fileCount":5,"unpackedSize":27549,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCqA/gGVf5K7ruhTwhxFBjSR1i2gwAAvCx2cApAHCw/lQIgP2Qr8lYfiU/HJnTsyV6lvnyr7kUs4JfvBOtr4OVcJjs="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+qc9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp5PA//RstijvnECfOLbbSXYiS1vZVLvSb9Uye2XueU5rNjsWTmWK7S\r\nQTpG5UJyoNf5iqVX2k7GQ2zSitogx/ywO9O+of8iwg5sAIdOV4i7e8NqpMUs\r\nDU6Akb+fW4NDvW2ZVPlLXRtdTDAaZnTutn+omB9ve8eK4FUo/3+dSGD9zKRN\r\norhp5pA2fh+js9n6dRYyltThaPALbSP1sUi1+QSR9Jxpax2zNAJQXUblLDJX\r\n2yQ3uDqgzqRACtWRSDD5FdINeQ/DXZ+gJ7LTsXHWYcKKvmW8Yymc49ln0LEK\r\nRE+X1XKryanTxmPzpyGih+7SfaaG1DeXZ9ZBigJp2U0+O8Cb1GYb3Isx3r8o\r\n8nFJiwHVcUljS8b4/DsDRYJ+luuNBxzCtyqpfDCwmizDT0+xzv8uBak9yDU5\r\nYWCRF6a4gbAKS0JJmLzuueu2WaIxpGxEAO0b1X2K3lNkv+Kc1j1O+lbovGYD\r\nVOkHb0+NpxFfGFBtzorNQcYpbqFcS6noR9A9paqGTBXalHIBjR14aXng8h7X\r\nFKPlVO3d8FaaN+ioD9LeFmPhno0Sdu3/Dag2rY9LQgtB9qQVoqDUMXwFx6zH\r\nCQczFcPT9yeAY+UcSEBvmPH4QCTiWQrnsZztsB8uBxwSYiPXSaU3pSlx0T1f\r\noBo+dE1VN1EUfu7bvS6Ybp9MxWOAL/gF10w=\r\n=Hy+y\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"reiner1210","email":"Reiner.Proels@gmail.com"},"directories":{},"maintainers":[{"name":"reiner1210","email":"Reiner.Proels@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mongo-express-session-store_1.0.16_1677371197537_0.7997584811782141"},"_hasShrinkwrap":false}},"time":{"created":"2023-02-24T23:11:05.120Z","1.0.0":"2023-02-24T23:11:05.338Z","modified":"2023-02-26T00:26:37.749Z","1.0.1":"2023-02-24T23:13:19.035Z","1.0.2":"2023-02-24T23:20:03.344Z","1.0.3":"2023-02-24T23:26:38.010Z","1.0.5":"2023-02-25T00:11:30.272Z","1.0.6":"2023-02-25T00:28:37.666Z","1.0.7":"2023-02-25T00:32:12.822Z","1.0.8":"2023-02-25T12:36:44.413Z","1.0.9":"2023-02-25T12:42:31.517Z","1.0.10":"2023-02-25T12:43:31.560Z","1.0.11":"2023-02-25T12:44:39.826Z","1.0.12":"2023-02-25T12:47:37.209Z","1.0.13":"2023-02-25T12:52:50.988Z","1.0.14":"2023-02-25T12:56:25.754Z","1.0.15":"2023-02-25T12:58:26.064Z","1.0.16":"2023-02-26T00:26:37.658Z"},"maintainers":[{"name":"reiner1210","email":"Reiner.Proels@gmail.com"}],"description":"Middleware to store expression session data in mongoDB Database. Using the official mogoDB driver, less dependencies and possibility to reuse the client / database for other database tasks.","keywords":["mongodb","express","session","ES6"],"author":{"name":"Reiner Pröls","email":"Reiner.Proels@gmail.com"},"license":"ISC","readme":"# MongoDB session store for using with express and express-session\n\nThis middleware uses the the official [MongoDB](https://www.mongodb.com/) driver for Node.js.\nI have tried to keep the dependencies as small as possible.\nIt is also possible to get the MongoDB client, database and collection\nfor other database tasks in the app.\nMongoDB recommends only to use one client per app.\nThe `getMongo` function will do the job. In a callback it delivers after connection the client, database and collection.\n\n## Installation\n\nAfter you've created your own project using `npm init`, you can run:\n\n```bash\nnpm install mongo-express-session-store\n```\nThis will download the session store and add a dependency entry in your `package.json` file.\n\n## Usage ##\n\n### Quickstart ###\n\n1. Install the package\n```bash\nnpm install mongo-express-session-store\n```\n\n2. Import the package in your source file\n```js\ncjs:\nconst mongoDBSessionStore = require('mongo-express-session-store')\n\nES6+:\nimport mongoDBSessionStore from 'mongo-express-session-store'\n```\n\n3. Get the store class\n```js\nconst MongoDBSessionStore = mongoDBSessionStore(session)\n```\n\n4. Create the store object\n```js\nconst MONGODB_URL = 'mongodb://USER:PASS@127.0.01:27017/?authSource=admin'\nconst mongoStore = new MongoDBSessionStore({\n    mongoUrl: MONGODB_URL,\n    databaseName: \"sessionTest\",\n    collectionName: \"sessions\"\n})\n```\n\n5. Set the store in the session\n```js\napp.use(session({\n    secret: 'Top secret ...',\n    cookie: {\n        maxAge: 3600*24*1000,\n    },\n    resave: false,\n    saveUninitialized: true,\n    store: mongoStore\n    })\n)\n```\n\n6. Get the MongoDB client, database and collection objects (optional)\n```js\nlet mongoClient = null\nlet mongoDatabase = null\nmongoStore.getMongo((client, database) => {\n    mongoClient = client\n    mongoDatabase = database\n    console.log('Client connected')\n})\n```\n\n#### Complete working example ####\n##### cjs #####\n```diff\n'use strict'\n\nconst express = require('express')\nconst session = require('express-session')\n+const mongoDBSessionStore = require('mongo-express-session-store')\n\nconst app = express()\n\n+const MongoDBSessionStore = mongoDBSessionStore(session)\n\n+const MONGODB_URL = 'mongodb://USER:PASS@127.0.01:27017/?authSource=admin'\n+const mongoStore = new MongoDBSessionStore(\n+    {\n+        mongoUrl: MONGODB_URL,\n+        databaseName: \"sessionTest\",\n+        collectionName: \"sessions\"\n+    }\n+)\n\n+let mongoClient = null\n+mongoStore.getMongo((client, database) => {mongoClient = client; console.log('Client connected')})\n\napp.use(session(\n    {\n        secret: 'Top secret ...',\n        cookie: {\n            maxAge: 3600*24*1000,\n        },\n        resave: false,\n        saveUninitialized: true,\n+       store: mongoStore\n    }\n))\n\napp.get('/', (req, res) => {\n    req.session.testValue = \"XXX\"\n    res.send(\"Hello\")\n})\n\napp.get('/test', (req, res) => {\n    res.send(req.session.testValue)\n})\n\napp.listen(3000)```\n```\n#### ES6 ####\n```diff\n'use strict'\n\nimport express from 'express'\nimport session from 'express-session'\n\n+import mongoDBSessionStore from 'mongo-express-session-store'\n\nconst app = express()\n\n+const MongoDBSessionStore = mongoDBSessionStore(session)\n\n+const MONGODB_URL = 'mongodb://USER:PASS@127.0.01:27017/?authSource=admin'\n+const mongoStore = new MongoDBSessionStore(\n+    {\n+        mongoUrl: MONGODB_URL,\n+        databaseName: \"sessionTest\",\n+        collectionName: \"sessions\"\n+    }\n+)\n\n+let mongoClient = null\n+mongoStore.getMongo((client, database) => {mongoClient = client; console.log('Client connected')})\n\napp.use(session(\n    {\n        secret: 'Ich weiss von nix',\n        cookie: {\n            maxAge: 3600*24*1000,\n        },\n        resave: false,\n        saveUninitialized: true,\n+       store: mongoStore\n    }\n))\n\napp.get('/', (req, res) => {\n    req.session.testValue = \"XXX\"\n    res.send(\"Hello\")\n})\n\napp.get('/test', (req, res) => {\n    res.send(req.session.testValue)\n})\n\napp.listen(3000)\n```\n\n#### Example ####\nIn the `doc` directory there is the source code for the example.\n\n## Test ##\nI have done some tests with [jest](https://www.npmjs.com/package/jest)\n\nFor this you need to create an .env file in the root of this project\nit must contain the [MongoDB URL](https://www.mongodb.com/docs/manual/reference/connection-string/):\nexample:\n> MONGODB_URL='mongodb://USER:PASS@127.0.01:27017/?authSource=admin'\n>\n>You have to urlencode `USER` and `PASS`\n\nFor the test I use the following database and collection names:\n>\n>databaseName: \"sessionUnitTest\"\n>\n>collectionName: \"sessions\"\n\nThen run the test with `npm test`.\n\n## License ##\n\n[ISC](https://www.isc.org/licenses/)\n\n© 2023 Reiner Pröls\n\n\n\n\n\n\n\n","readmeFilename":"README.md","homepage":"https://github.com/Reiner1210/mongo-express-session-store","repository":{"type":"git","url":"git+https://github.com/Reiner1210/mongo-express-session-store.git"},"bugs":{"url":"https://github.com/Reiner1210/mongo-express-session-store/issues"}}