express-session-resolver
This module makes you to get session-id from the cookie which the id is generated by express-session.
Requirement
- using express-session
- stored the session MySQL Server by express-mysql-session
Usecase
Suppose that they have 2 same domain's servers, Socket IO's sever is able to authenticate reauests the by cookie which is generated from the express server. express-session-resolver convert cookie to session-id, and queries to MySQL server.
How to use
npm install express-session-resolver
then,
const Resolver = ;const resolver = mysql: host: "your my sql server's host" port: "the port" user: "the user" password: "the password" database: "the database name" name: "cookie name" secret: "secret"; // --------------------------------// For example, Socket IO's server// At 1st, you can use middleware for auth. const authMiddleware = { return { const noCookies = !sockethandshakeheaders || !sockethandshakeheaderscookie if noCookies return const session = await resolver if session else }}// add it as a middleware io // --------------------------------// For example, express serverapp