Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #475 from Fdawgs/refactor/server
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Jan 11, 2022
2 parents de5380e + 180d8a4 commit f3fd622
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-security-node": "^1.1.0",
"faker": "^5.5.3",
"faker": "5.5.3",
"glob": "^7.2.0",
"husky": "^7.0.4",
"jest": "^27.4.7",
Expand Down
12 changes: 6 additions & 6 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ async function plugin(server, config) {
.register(flocOff)

// Use Helmet to set response security headers: https://helmetjs.github.io/
.register(helmet, config.helmet);
.register(helmet, config.helmet)

await server
// Rate limiting and 429 response handling
.register(rateLimit, config.rateLimit);

server
// Utility functions and error handlers
.register(sensible, { errorHandler: false })

Expand All @@ -50,6 +45,11 @@ async function plugin(server, config) {
// Process load and 503 response handling
.register(underPressure, config.processLoad);

await server
// Rate limiting and 429 response handling
.register(rateLimit, config.rateLimit);

// Register routes
server
// Ensure rate limit also applies to 4xx and 5xx responses
.addHook("onSend", server.rateLimit())
Expand Down

0 comments on commit f3fd622

Please sign in to comment.