-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hi,
What is the recommended way to use hono-session with createFactory in hono?
I have tried this based on README.md
It works, but fails type check in Deno. Here is the code:
const factoryWithSession = createFactory<{ Variables: {
session: Session<SessionDataTypes>,
session_key_rotation: boolean
} }>();
const app = factoryWithSession.createApp();
app.use('*', sessionMiddleware({
store,
encryptionKey: 'password_at_least_32_characters_long', // Required for CookieStore, recommended for others.
// You can also supply a function instead of a plain string
// encryptionKey: () => 'function_that_returns_a_long_string'
expireAfterSeconds: 900, // Expire session after 15 minutes of inactivity
autoExtendExpiration: true, // Extend the session expiration time automatically. Defaults to true
cookieOptions: {
sameSite: 'Lax', // Recommended for basic CSRF protection in modern browsers
path: '/', // Required for this library to work properly
httpOnly: true, // Recommended to avoid XSS attacks
},
}))
And here is the type check error:
TS2769 [ERROR]: No overload matches this call.
The last overload gave the following error.
Argument of type 'MiddlewareHandler' is not assignable to parameter of type 'MiddlewareHandler<{ Variables: { session: Session<SessionDataTypes>; session_key_rotation: boolean; }; }, "*", {}>'.
Types of parameters 'c' and 'c' are incompatible.
Type 'Context<{ Variables: { session: Session<SessionDataTypes>; session_key_rotation: boolean; }; }, "*", {}>' is not assignable to type 'Context<any, string, {}>'.
The types of 'req.matchedRoutes' are incompatible between these types.
Metadata
Metadata
Assignees
Labels
No labels