cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

An expression-session-store for Neo4j

jan1
Node

Hi everyone.

I wrote a session store for neo4j and express-session. You can use it with

npm install neo4j-session-store

The use case is here that you want a web session store on Neo4j, for example because you only want to have one database in your app.

const STORE_OPTIONS = {
  table: {
    name: "sessions",
    hashKey: "sessionId",
    hashPrefix: "sessions:",
  },
  neo4jConfig: {
    neo4jurl: "bolt://localhost:7687",
    neo4juser: "neo4j",
    neo4jpwd: "test",
  },
  touchInterval: 0,
};

var Neo4jSessionStore = require('Neo4jSessionStore').default;

var sessionConfig = {
    secret: 'mysecret',
    store: new Neo4jSessionStore(STORE_OPTIONS),
    resave: false,
    saveUninitialized: false,
    genid: (req) => {
        return uuidv4(); 
    },
    cookie: {
        httpOnly: true,
        sameSite: 'strict',
    }
}

app.use(session(sessionConfig));

Yours,

Jan Brogger

0 REPLIES 0