Skip to content

Commit

Permalink
test: GET endpoints should respond to HEAD reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
rickdgeerling committed Sep 23, 2024
1 parent 5ae7e0f commit 4d46bd8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions integration/hello-world/e2e/express-instance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ describe('Hello world (express instance)', () => {
});
});

it('/HEAD should respond to with a 200', () => {
return request(server).head('/hello').expect(200);
});

afterEach(async () => {
await app.close();
});
Expand Down
9 changes: 9 additions & 0 deletions integration/hello-world/e2e/fastify-adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ describe('Hello world (fastify adapter)', () => {
.then(({ payload }) => expect(payload).to.be.eql('Hello world!'));
});

it('/HEAD should respond to with a 200', () => {
return app
.inject({
method: 'HEAD',
url: '/hello',
})
.then(({ statusCode }) => expect(statusCode).to.be.eq(200));
});

afterEach(async () => {
await app.close();
});
Expand Down
5 changes: 4 additions & 1 deletion packages/platform-fastify/adapters/fastify-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,10 @@ export class FastifyAdapter<
return rawRequest.originalUrl || rawRequest.url;
}

private injectRouteOptions(routerMethodKey: HTTPMethods, ...args: any[]) {
private injectRouteOptions(
routerMethodKey: Uppercase<HTTPMethods>,
...args: any[]
) {
const handlerRef = args[args.length - 1];
const isVersioned =
!isUndefined(handlerRef.version) &&
Expand Down

0 comments on commit 4d46bd8

Please sign in to comment.