{"id":18853882,"url":"https://github.com/benweier/connect-session-firestore","last_synced_at":"2025-04-14T10:32:41.222Z","repository":{"id":57205784,"uuid":"125176091","full_name":"benweier/connect-session-firestore","owner":"benweier","description":"A Connect/Express session store powered by the Firebase Cloud Firestore.","archived":false,"fork":false,"pushed_at":"2018-07-16T23:21:01.000Z","size":25,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T23:41:50.730Z","etag":null,"topics":["connect","cookie","express","firebase","firestore","node","session"],"latest_commit_sha":null,"homepage":"","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/benweier.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.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-03-14T07:57:05.000Z","updated_at":"2018-09-04T13:54:41.000Z","dependencies_parsed_at":"2022-09-18T01:22:18.528Z","dependency_job_id":null,"html_url":"https://github.com/benweier/connect-session-firestore","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/benweier%2Fconnect-session-firestore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benweier%2Fconnect-session-firestore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benweier%2Fconnect-session-firestore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benweier%2Fconnect-session-firestore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benweier","download_url":"https://codeload.github.com/benweier/connect-session-firestore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248483445,"owners_count":21111450,"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":["connect","cookie","express","firebase","firestore","node","session"],"created_at":"2024-11-08T03:46:01.228Z","updated_at":"2025-04-14T10:32:41.161Z","avatar_url":"https://github.com/benweier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Connect Session Firestore\n\n[![Travis](https://img.shields.io/travis/benweier/connect-session-firestore.svg?maxAge=2592000\u0026style=flat-square)](https://travis-ci.org/benweier/connect-session-firestore)\n[![Codecov](https://img.shields.io/codecov/c/github/benweier/connect-session-firestore.svg?maxAge=2592000\u0026style=flat-square)](https://codecov.io/gh/benweier/connect-session-firestore)\n[![Greenkeeper badge](https://img.shields.io/badge/greenkeeper-enabled-brightgreen.svg?style=flat-square)](https://greenkeeper.io/)\n\n`connect-session-firestore` is a Connect/Express compatible session store backed by the [Firebase SDK](https://firebase.google.com/docs/admin/setup).\n\n## Installation\n\n`firebase-admin` must be added as a peer dependency, or you're gonna have a bad time.\n\n    $ npm install firebase-admin connect-session-firestore --save\n\n## Options\n\n  - `database` A pre-initialized Firebase Cloud Firestore app.\n  - `sessions` (optional) A document reference string for session storage. (defaults to \"sessions\")\n  - `reapInterval` (optional) How often expired sessions should be cleaned up (defaults to 21600000) (6 hours in milliseconds)\n  - `reapCallback` (optional) A callback function to execute whenever a session clean up occurs\n\n## Usage\n\nInitialize `firebase-admin` database and pass the instance to `FirestoreStore`. Connecting to the database requires a credential cert via a JSON file from the [Firebase IAM \u0026 Admin Console](https://console.firebase.google.com/iam-admin/projects).\n\n* [Connect](http://senchalabs.github.io/connect)\n\n```js\nconst connect = require('connect');\nconst FirestoreStore = require('connect-session-firestore')(connect);\nconst firebase = require('firebase-admin');\nconst ref = firebase.initializeApp({\n  credential: firebase.credential.cert('path/to/serviceAccountCredentials.json'),\n  databaseURL: 'https://databaseName.firebaseio.com'\n});\n\nconnect()\n  .use(connect.cookieParser())\n  .use(connect.session({\n    store: new FirestoreStore({\n      database: ref.firestore()\n    }),\n    secret: 'keyboard cat'\n  }));\n```\n\n* [Express](http://expressjs.com)\n\n  **NOTE:** In Express 4 `express-session` must be passed to the function `connect-session-firestore` exports in order to extend `express-session.Store`:\n\n```js\nconst express = require('express');\nconst session = require('express-session');\nconst FirestoreStore = require('connect-session-firestore')(session);\nconst firebase = require('firebase-admin');\nconst ref = firebase.initializeApp({\n  credential: firebase.credential.cert('path/to/serviceAccountCredentials.json'),\n  databaseURL: 'https://databaseName.firebaseio.com'\n});\n\nexpress()\n  .use(session({\n    store: new FirestoreStore({\n      database: ref.firestore()\n    }),\n    secret: 'keyboard cat'\n    resave: true,\n    saveUninitialized: true\n  }));\n```\n\n## Tests\n\nTo run tests against `connect-session-firestore` you will need your own Firebase Database app available.\n\nCheckout the repo locally and create two files in the project root:\n- .env\n- serviceAccountCredentials.json\n\nWith the content:\n\n*.env*\n```\nFIREBASE_SERVICE_ACCOUNT=./serviceAccountCredentials.json\nFIREBASE_DATABASE_URL=https://[databaseName].firebaseio.com\n```\n\n*serviceAccountCredentials.json*\n```\n{\n  \"type\": \"service_account\",\n  \"project_id\": \"\",\n  \"private_key_id\": \"\",\n  \"private_key\": \"\",\n  \"client_email\": \"\",\n  \"client_id\": \"\",\n  \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n  \"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\n  \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n  \"client_x509_cert_url\": \"\"\n}\n```\n\nInstall the dev dependencies:\n\n    $ npm install\n\nRun the tests:\n\n    $ npm test\n\n## License\n\n`connect-session-firestore` is licensed under the [MIT license](https://github.com/benweier/connect-session-firestore/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenweier%2Fconnect-session-firestore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenweier%2Fconnect-session-firestore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenweier%2Fconnect-session-firestore/lists"}