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

Commit

Permalink
refactor: chain response functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Mar 28, 2022
1 parent 23f782c commit 860c425
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/routes/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ async function route(server) {
}
},
handler: (req, res) => {
res.removeHeader("pragma");
res.removeHeader("expires");
res.removeHeader("surrogate-control");
res.header("cache-control", "private, max-age=180");
res.type("text/html; charset=utf-8");
res.sendFile("index.html");
res.header("cache-control", "private, max-age=180")
.removeHeader("pragma")
.removeHeader("expires")
.removeHeader("surrogate-control")
.type("text/html; charset=utf-8")
.sendFile("index.html");
},
});
}
Expand Down
10 changes: 5 additions & 5 deletions src/routes/docs/json/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ async function route(server, options) {
}
},
handler: (req, res) => {
res.removeHeader("pragma");
res.removeHeader("expires");
res.removeHeader("surrogate-control");
res.header("cache-control", "public, max-age=3600");
res.send(server.swagger());
res.header("cache-control", "public, max-age=3600")
.removeHeader("pragma")
.removeHeader("expires")
.removeHeader("surrogate-control")
.send(server.swagger());
},
});
}
Expand Down
11 changes: 6 additions & 5 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ async function plugin(server, config) {
!res.getHeader("content-type")?.includes("html") &&
!res.getHeader("content-type")?.includes("xml")
) {
res.raw.setHeader(
"content-security-policy",
"default-src 'self';frame-ancestors 'none'"
);
res.raw.removeHeader("x-xss-protection");
res.raw
.setHeader(
"content-security-policy",
"default-src 'self';frame-ancestors 'none'"
)
.removeHeader("x-xss-protection");
}
return res;
})
Expand Down

0 comments on commit 860c425

Please sign in to comment.