Skip to content

Commit

Permalink
Move "simple" middleware functions inline
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn committed Jul 28, 2020
1 parent dda8ab5 commit e657b0b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
18 changes: 8 additions & 10 deletions middlewares/x-download-options/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { IncomingMessage, ServerResponse } from "http";

function xDownloadOptionsMiddleware(
_req: IncomingMessage,
res: ServerResponse,
next: () => void
): void {
res.setHeader("X-Download-Options", "noopen");
next();
}

function xDownloadOptions() {
return xDownloadOptionsMiddleware;
return function xDownloadOptionsMiddleware(
_req: IncomingMessage,
res: ServerResponse,
next: () => void
): void {
res.setHeader("X-Download-Options", "noopen");
next();
};
}

module.exports = xDownloadOptions;
Expand Down
18 changes: 8 additions & 10 deletions middlewares/x-powered-by/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { IncomingMessage, ServerResponse } from "http";

function xPoweredByMiddleware(
_req: IncomingMessage,
res: ServerResponse,
next: () => void
) {
res.removeHeader("X-Powered-By");
next();
}

function xPoweredBy() {
return xPoweredByMiddleware;
return function xPoweredByMiddleware(
_req: IncomingMessage,
res: ServerResponse,
next: () => void
) {
res.removeHeader("X-Powered-By");
next();
};
}

module.exports = xPoweredBy;
Expand Down
18 changes: 8 additions & 10 deletions middlewares/x-xss-protection/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { IncomingMessage, ServerResponse } from "http";

function xXssProtectionMiddleware(
_req: IncomingMessage,
res: ServerResponse,
next: () => void
) {
res.setHeader("X-XSS-Protection", "0");
next();
}

function xXssProtection() {
return xXssProtectionMiddleware;
return function xXssProtectionMiddleware(
_req: IncomingMessage,
res: ServerResponse,
next: () => void
) {
res.setHeader("X-XSS-Protection", "0");
next();
};
}

module.exports = xXssProtection;
Expand Down

0 comments on commit e657b0b

Please sign in to comment.