Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/webcc/cassandra-store
Implementation of the session storage in Apache Cassandra as express middleware.
https://github.com/webcc/cassandra-store
cassandra cassandra-client express-middleware javascript nodejs
Last synced: 2 months ago
JSON representation
Implementation of the session storage in Apache Cassandra as express middleware.
- Host: GitHub
- URL: https://github.com/webcc/cassandra-store
- Owner: webcc
- License: other
- Created: 2014-10-01T07:22:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-24T18:18:36.000Z (over 6 years ago)
- Last Synced: 2024-10-16T10:32:10.408Z (4 months ago)
- Topics: cassandra, cassandra-client, express-middleware, javascript, nodejs
- Language: JavaScript
- Size: 57.6 KB
- Stars: 14
- Watchers: 6
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
cassandra-store
===============[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][npm-downloads]][npm-url]
![Node][node-version]Implementation of the session storage in [Apache Cassandra][cassandra]
as an extension of the [express-session middleware][express-session].
This version has been fully updated to ES6 and Node.js >= 10. For backwards
compatibility, use older versions of the package.## Installation
```shell
$ npm install [-g] cassandra-store
```## Options
```json
{
"table": "sessions",
"client": null,
"clientOptions": {
"contactPoints": [ "localhost" ],
"keyspace": "tests",
"queryOptions": {
"prepare": true
}
}
}
```If `client` is `null` or undefined, a new Cassandra client will be created.
Client options come from the [Cassandra client driver][cassandra-driver] (version 3.x).## Configuring the database
To create the table in the Cassandra database, you need the execute the
following CQL commands:```
USE tests;DROP TABLE IF EXISTS sessions;
CREATE TABLE IF NOT EXISTS sessions (
sid text,
session text,
expires timestamp,
PRIMARY KEY(sid)
);
```## Debugging
To activate debugging, set the environment variable `NODE_DEBUG`:
```shell
$ export NODE_DEBUG=cassandra-store
```## Testing
See [test/README.md](test/README.md)
## Usage
Usage within express:
```javascript
const session = require("express-session");
const CassandraStore = require("cassandra-store");app.use(session({
store: new CassandraStore(options),
...
}));
```## TODO
- Update to Cassandra driver Promises API
[cassandra]: https://cassandra.apache.org/
[cassandra-driver]: https://docs.datastax.com/en/developer/nodejs-driver/3.5/
[express-session]: https://github.com/expressjs/session
[node-version]: https://img.shields.io/badge/node-10-orange.svg?style=flat-square
[npm-image]: https://img.shields.io/badge/npm-5.1.0-blue.svg?style=flat-square
[npm-downloads]: https://img.shields.io/badge/downloads-12k-red.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/cassandra-store