Connect Migration Store for express
This lib is here to help you migrate from an existing session store to another without disconnecting your users.
Project can be found on npm, and installed with a classic npm i
.
npm install --save connect-migration-store
To use migration store, you need to instantiate your migration store with two store: the original one you want to migrate from, and the new one you want to migrate to. Then you can feed it to the session express middleware.
Here is below an example migrating from redis to dynamodb:
const express = require('express');
const session = require('express-session');
const DynamoDBStore = require('connect-dynamodb')({session});
const RedisStore = require('connect-redis')(session);
const MigrationStore = require('connect-migration-store')(session);
// Store creation
const originalStore = new RedisStore({url: 'some-redis-url'});
const newStore = new DynamoDBStore({table: 'some-dynamodb-table'});
const migrationStore = new MigrationStore({from: originalStore, to: newStore})
// instiate app with express then load session middleware with migration store
const app = express();
app.use(session({store: migrationStore, secret: '42'});
// and do what you need with your server
Then deploy, let it in place for few days, the duration of your migration. Then you can remove it and replace it with the new store. Your migration is now complete 😉
Licence is MIT. If there is a feature you want to add, or bug you want to report, just open an issue, or fork and submit a PR.