Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including cloud-datastore-session with all npm packages installed. Try it out:

var cloudDatastoreSession = require("cloud-datastore-session")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

cloud-datastore-session v0.1.0

Google Cloud Datastore session store for Express/Connect

Google Cloud Datastore Sessions

cloud-datastore-session is a Express session storage backed by Google Cloud Datastore.

Note: Cloud Datastore is a persistent, distributed, transactional database. Often, it's more appropriate to choose a different storage solution for sessions such as Memcache or Redis as their designs offer much faster operation in this use case.

Installation

$ npm install --save cloud-datastore-session

Configuration

You must have a Google Cloud project and credentials. See gcloud node's documentation on setting up authorization.

Usage Example

var express = require('express');
var session = require('express-session');
var app = express();

var DatastoreStore = require('cloud-datastore-session')(session);

app.use(session({
  store: new DatastoreStore({
    dataset: gcloud.datastore.dataset({
        prefix: 'express-sessions',
        projectId: 'my-project-id',
        keyFilename: './key.json'
    }))
  }),
  secret: 'my-secret'
}));

Contributing changes

Licensing

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free