Skip to content

Commit

Permalink
Add Fastify example (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 committed Mar 21, 2024
1 parent cc88111 commit 187b9e1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Expand Up @@ -43,6 +43,26 @@ closeWithGrace(
})
```

### Example with Fastify

```js
import fastify from 'fastify'
import closeWithGrace from 'close-with-grace'

const app = fastify()

closeWithGrace(async function ({ signal, err, manual }) {
if (err) {
app.log.error({ err }, 'server closing with error')
} else {
app.log.info(`${signal} received, server closing`)
}
await app.close()
})

await app.listen()
```

## API

### `closeWithGrace([opts], fn({ err, signal, manual }))`
Expand Down

0 comments on commit 187b9e1

Please sign in to comment.