Skip to content

Commit cad5d89

Browse files
committed
fix(fastify): inverse fallthrough condition
1 parent eb0ab9e commit cad5d89

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/loaders/fastify.loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class FastifyLoader extends AbstractLoader {
4141
}
4242

4343
const renderFn = (req: any, res: any) => {
44-
if (options.serveStaticOptions?.fallthrough) {
44+
if (!options.serveStaticOptions?.fallthrough) {
4545
const error = new NotFoundException();
4646
res.status(error.getStatus()).send(error.getResponse());
4747
return;

tests/e2e/fastify-adapter.e2e-spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from '@nestjs/platform-fastify';
66
import { AppModule } from '../src/app.module';
77
import { NoopLogger } from '../utils/noop-logger';
8+
import request from 'supertest';
89

910
describe('Fastify adapter', () => {
1011
let app: NestFastifyApplication;
@@ -82,14 +83,15 @@ describe('Fastify adapter', () => {
8283
});
8384

8485
describe('when trying to get a non-existing file', () => {
85-
it('should return 404', async () => {
86+
it('should returns index page', async () => {
8687
return app
8788
.inject({
8889
method: 'GET',
8990
url: '/404'
9091
})
9192
.then((result) => {
92-
expect(result.statusCode).toEqual(404);
93+
expect(result.statusCode).toEqual(200);
94+
expect(result.payload).toContain('Static website');
9395
});
9496
});
9597
});
@@ -172,15 +174,14 @@ describe('Fastify adapter', () => {
172174
});
173175

174176
describe('when trying to get a non-existing file', () => {
175-
it('should returns index page', async () => {
177+
it('should return 404', async () => {
176178
return app
177179
.inject({
178180
method: 'GET',
179181
url: '/404'
180182
})
181183
.then((result) => {
182-
expect(result.statusCode).toEqual(200);
183-
expect(result.payload).toContain('Static website');
184+
expect(result.statusCode).toEqual(404);
184185
});
185186
});
186187
});

0 commit comments

Comments
 (0)