fastify / fastify-secure-session

Create a secure stateless cookie session for Fastify
MIT License
201 stars 45 forks source link

add support for custom session key and multiple sessions #186

Closed jsprw closed 1 year ago

jsprw commented 1 year ago

Useful for #178 and #162. This PR is continuation of #163 by @Uzlopak which was closed because of conflicting decorators. In this PR it uses a different approach: it uses an array of options that each will create a session instead of registering the plugin multiple times.

To use the decorators, you will have to pass the sessionKey so it selects the right key for decoding/encoding. To not introduce a breaking change, the first registered session will act as the default session.

It looks like a lot has changed, but that is mainly due to the introduction of the for-loops and indentation.

Checklist