GoogleCloudPlatform/cloud-datastore-session-node

Name: cloud-datastore-session-node

Owner: Google Cloud Platform

Description: Session storage for express.js using Google Cloud Datastore

Created: 2015-03-18 18:25:06.0

Updated: 2018-05-01 03:18:30.0

Pushed: 2018-05-01 03:18:27.0

Homepage:

Size: 51

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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
Datastore = require('@google-cloud/datastore');

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

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

use(session({
ore: 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
})
,
cret: 'my-secret'

Contributing
License

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.