Skip to content

Commit

Permalink
Exclude HEAD and OPTIONS methods
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimon committed Jan 11, 2024
1 parent f629328 commit 686f732
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/express/listEndpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ const parseStack = function (stack, basePath, endpoints) {
const getEndpoints = function (app) {
const endpoints = parseEndpoints(app);
return endpoints.flatMap((route) =>
route.methods.map((method) => ({
method,
path: route.path,
})),
route.methods
.filter((method) => !["HEAD", "OPTIONS"].includes(method.toUpperCase()))
.map((method) => ({
method,
path: route.path,
})),
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/fastify/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const apitallyPlugin: FastifyPluginAsync<ApitallyConfig> = async (
: [routeOptions.method];
methods.forEach((method) => {
routeOptions.onSend;
if (method !== "HEAD") {
if (!["HEAD", "OPTIONS"].includes(method.toUpperCase())) {
routes.push({
method: method,
method: method.toUpperCase(),
path: routeOptions.url,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/koa/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const listEndpoints = (app: Koa) => {
middleware.router.stack.forEach((layer: any) => {
if (layer.methods && layer.methods.length > 0) {
layer.methods.forEach((method: string) => {
if (method.toUpperCase() !== "HEAD") {
if (!["HEAD", "OPTIONS"].includes(method.toUpperCase())) {
endpoints.push({
method: method.toUpperCase(),
path: layer.path,
Expand Down

0 comments on commit 686f732

Please sign in to comment.