-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filestore with next session #363
Comments
import nextSession from "next-session";
import { promisifyStore } from "next-session/lib/compat";
import {FirestoreStore} = from '@google-cloud/connect-firestore';
const firestoreStore = new FirestoreStore({
dataset: new Firestore(),
kind: 'express-sessions',
})
const getSession = nextSession({
store: promisifyStore(firestoreStore),
}); |
https://www.npmjs.com/package/session-file-store
It does not work
So Either filesystem store or Prisma connection, anyone of them is a solution. although i prefer file store then pure pg then prisma |
What does not work for you when using filestore? Do you specify a path for it to use? Also, keep in mind that some deployment options (like Vercel) does not allow you to save files. |
Ok thanx , so how to use barebone Postgres as a session datastore |
First you want to pick a session store. https://github.com/expressjs/session#compatible-session-stores is a good start. Then you want to take a look at this section: https://github.com/hoangvvo/next-session#compatibility-with-expressconnect-stores. For example, let's use https://www.npmjs.com/package/connect-pg-simple. import pg from 'pg';
import { expressSession } from "next-session/lib/compat";
import connectPgSimple from "connect-pg-simple";
const pgSession = connectPgSimple(expressSession);
const pgPool = new pg.Pool({
// Insert pool options here
});
const getSession = nextSession({
store: promisifyStore(new pgSession({
pool : pgPool,
tableName : 'user_sessions'
}))
});
export default async function session(req, res, next) {
await getSession(req, res);
next();
} If it does not work, let me know exactly what is the issue you are having (stack trace/behavior). |
It does not work as session is |
Could you post the stack trace? |
|
this works without errs |
Did you follow the steps in https://github.com/voxpelli/node-connect-pg-simple#connect-pg-simple, in particular, creaing a session table with their schema? I have tested |
how to use db or filestore as a session storage as memory is not suited for production.?
The text was updated successfully, but these errors were encountered: