Skip to content

Commit

Permalink
fix: binding to the FastifyInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
wobsoriano committed Dec 17, 2022
1 parent 00cdb3d commit 61600ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -56,7 +56,7 @@ signOut()

```ts
fastify.get('/api/user', async (req) => {
const { user } = await fastify.getSession(req)
const { user } = await this.getSession(req)
return user
})
```
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Expand Up @@ -32,7 +32,8 @@ const plugin: FastifyPluginCallback<AuthOptions> = async (
}

fastify.addHook('onRequest', runMiddie)
fastify.decorate('getSession', (req: FastifyRequest) => {
// eslint-disable-next-line prefer-arrow-callback
fastify.decorate('getSession', function (req: FastifyRequest) {
return getSession(req.raw, options)
})

Expand Down

0 comments on commit 61600ae

Please sign in to comment.