Skip to content
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

fix: don't use decorateRequest with reference types #138

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/fastifySession.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ function session (fastify, options, next) {
fastify.decorate('decryptSession', (sessionId, request, callback) => {
decryptSession(sessionId, options, request, callback)
})
fastify.decorateRequest('sessionStore', options.store)
fastify.decorateRequest('session', {})
fastify.decorateRequest('sessionStore', null)
fastify.decorateRequest('session', null)
fastify.decorateRequest('destroySession', destroySession)
fastify.addHook('preValidation', preValidation(options))
fastify.addHook('onSend', onSend(options))
fastify.addHook('onRequest', (req, reply, next) => {
req.sessionStore = options.store
req.session = {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor but I think this line is not necessary since it always gets assigned to either a new session or an existing one by the preValidation hook right? (I could have missed something, if so feel free to ignore this)

next()
})
next()
}

Expand Down