npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

@google-cloud/connect-datastore

2.0.2 • Public • Published
Google Inc. logo

Google Cloud Datastore Sessions

NPM

@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 @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

const {Datastore} = require('@google-cloud/datastore');
const express = require('express');
const session = require('express-session');
const app = express();
 
const DatastoreStore = require('@google-cloud/connect-datastore')(session);
 
app.use(session({
  store: new DatastoreStore({
    dataset: new Datastore({
      kind: '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

Keywords

none

install

npm i @google-cloud/connect-datastore

Downloadsweekly downloads

1,271

version

2.0.2

license

Apache-2.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability