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

Commit

Permalink
perf(plugins/hashed): decorate request to stop object deoptimisation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Jun 29, 2023
1 parent 8937c15 commit 7af2683
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/plugins/hashed-bearer-auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const secJSON = require("secure-json-parse");
* @param {import("fastify").FastifyInstance} server - Fastify instance.
*/
async function plugin(server) {
server.decorateRequest("scopes", null);

await server.register(bearer, {
errorResponse: (err) => ({
statusCode: 401,
Expand Down
1 change: 1 addition & 0 deletions src/routes/documents/receipt/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe("Receipt route", () => {

server = Fastify();
await server
.decorateRequest("scopes", null)
.addHook("preValidation", async (req) => {
req.scopes = [
"documents/receipt.delete",
Expand Down
1 change: 1 addition & 0 deletions src/routes/documents/register/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ describe("Register route", () => {
await server
.register(cleanObject)
.register(convertDateParamOperator)
.decorateRequest("scopes", null)
.addHook("preValidation", async (req) => {
req.scopes = ["documents/register.search"];
})
Expand Down
1 change: 1 addition & 0 deletions src/routes/preferences/options/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe("Options route", () => {
server = Fastify();
await server
.register(cleanObject)
.decorateRequest("scopes", null)
.addHook("preValidation", async (req) => {
req.scopes = ["preferences/options.search"];
})
Expand Down
1 change: 1 addition & 0 deletions src/routes/preferences/user/route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ describe("User route", () => {
server = Fastify();
await server
.register(cleanObject)
.decorateRequest("scopes", null)
.addHook("preValidation", async (req) => {
req.scopes = [
"preferences/user.put",
Expand Down

0 comments on commit 7af2683

Please sign in to comment.