Skip to content

sceee/cloud-datastore-session-node

This branch is 2 commits ahead of, 239 commits behind googleapis/nodejs-datastore-session:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1a4249e · Sep 22, 2018

History

16 Commits
Jan 9, 2017
Sep 22, 2018
Jan 9, 2017
Mar 12, 2015
Jan 9, 2017
Jan 9, 2017
Jan 10, 2017
Jan 9, 2017
Jan 8, 2018
Jan 9, 2017
Jan 9, 2017
Sep 22, 2018
Jan 9, 2017

Repository files navigation

Google Inc. logo

Google Cloud Datastore Sessions

NPM Tests Coverage

@google-cloud/connect-datastore is a Google Cloud Datastore session store 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 @google-cloud/connect-datastore

or

yarn add @google-cloud/connect-datastore

Configuration

You must have a Google Cloud project and credentials.

See gcloud node's documentation on setting up authentication.

Usage Example

var Datastore = require('@google-cloud/datastore');

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

var DatastoreStore = require('@google-cloud/connect-datastore')(session);

app.use(session({
  store: new DatastoreStore({
    dataset: Datastore({
      prefix: 'express-sessions',

      // For convenience, @google-cloud/datastore automatically looks for the
      // GCLOUD_PROJECT environment variable. Or you can explicitly pass in a
      // project ID here:
      projectId: 'YOUR_PROJECT_ID' || process.env.GCLOUD_PROJECT,

      // For convenience, @google-cloud/datastore automatically looks for the
      // GOOGLE_APPLICATION_CREDENTIALS environment variable. Or you can
      // explicitly pass in that path to your key file here:
      keyFilename: '/path/to/keyfile.json' || process.env.GOOGLE_APPLICATION_CREDENTIALS
    })
  }),
  secret: 'my-secret'
}));

Contributing

License

About

Session storage for express.js using Google Cloud Datastore

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%