Skip to content

Commit

Permalink
docs(readme), test: generateCsrf no longer require await (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
5t111111 authored Sep 17, 2024
1 parent 267aba1 commit 0bef4a8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fastify.route({
method: 'GET',
path: '/',
handler: async (req, reply) => {
const token = await reply.generateCsrf()
const token = reply.generateCsrf()
return { token }
}
})
Expand Down Expand Up @@ -77,7 +77,7 @@ fastify.route({
method: 'GET',
path: '/',
handler: async (req, reply) => {
const token = await reply.generateCsrf()
const token = reply.generateCsrf()
return { token }
}
})
Expand Down Expand Up @@ -107,7 +107,7 @@ fastify.route({
method: 'GET',
path: '/',
handler: async (req, reply) => {
const token = await reply.generateCsrf()
const token = reply.generateCsrf()
return { token }
}
})
Expand Down Expand Up @@ -153,7 +153,7 @@ Apart from these safeguards, it is extremely important to [use HTTPS for your we
Generates a secret (if it is not already present) and returns a promise that resolves to the associated secret.

```js
const token = await reply.generateCsrf()
const token = reply.generateCsrf()
```

You can also pass the [cookie serialization](https://github.com/fastify/fastify-cookie) options to the function.
Expand Down
2 changes: 1 addition & 1 deletion examples/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fastify.route({
method: 'GET',
url: '/',
handler: async (req, reply) => {
const token = await reply.generateCsrf()
const token = reply.generateCsrf()
reply.type('text/html')

return `
Expand Down
6 changes: 3 additions & 3 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test('Cookies', t => {
const fastify = await load()

fastify.get('/', async (req, reply) => {
const token = await reply.generateCsrf()
const token = reply.generateCsrf()
return { token }
})

Expand Down Expand Up @@ -179,7 +179,7 @@ function runTest (t, load, tkn, hook = 'onRequest') {
const fastify = await load()

fastify.get('/', async (req, reply) => {
const token = await reply.generateCsrf()
const token = reply.generateCsrf()
return { token }
})

Expand Down Expand Up @@ -274,7 +274,7 @@ function runCookieOpts (t, load) {
const fastify = await load()

fastify.get('/', async (req, reply) => {
const token = await reply.generateCsrf({ path: '/hello' })
const token = reply.generateCsrf({ path: '/hello' })
return { token }
})

Expand Down
6 changes: 3 additions & 3 deletions test/user-info.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test('Cookies with User-Info', async t => {
}

fastify.post('/login', async (req, reply) => {
const token = await reply.generateCsrf({ userInfo: userInfoDB[req.body.username] })
const token = reply.generateCsrf({ userInfo: userInfoDB[req.body.username] })
return { token }
})

Expand Down Expand Up @@ -84,7 +84,7 @@ test('Session with User-Info', async t => {

fastify.post('/login', async (req, reply) => {
req.session.username = req.body.username
const token = await reply.generateCsrf({ userInfo: req.body.username })
const token = reply.generateCsrf({ userInfo: req.body.username })
return { token }
})

Expand Down Expand Up @@ -136,7 +136,7 @@ test('SecureSession with User-Info', async t => {

fastify.post('/login', async (req, reply) => {
req.session.set('username', req.body.username)
const token = await reply.generateCsrf({ userInfo: req.body.username })
const token = reply.generateCsrf({ userInfo: req.body.username })
return { token }
})

Expand Down

0 comments on commit 0bef4a8

Please sign in to comment.