Skip to content

Commit

Permalink
Merge branch 'master' into feat/validation-pipe-option
Browse files Browse the repository at this point in the history
  • Loading branch information
civilcoder55 authored Jan 9, 2025
2 parents 7fbfa8a + 8f04235 commit 09d5963
Show file tree
Hide file tree
Showing 519 changed files with 35,398 additions and 21,200 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ parameters:
default: false
legacy-node-version:
type: string
default: '14.21.3'
default: '18.20'
maintenance-node-version:
type: string
default: '16.20'
default: '20.18'
active-node-version:
type: string
default: '18.17'
default: '22.11'
current-node-version:
type: string
default: '20.5'
default: '23.3'

aliases:
- &restore-cache
Expand Down Expand Up @@ -121,14 +121,14 @@ jobs:
lint:
working_directory: ~/nest
docker:
- image: cimg/node:<< pipeline.parameters.current-node-version >>
- image: cimg/node:<< pipeline.parameters.active-node-version >>
steps:
- checkout
- *restore-cache
- *install-deps
- run:
name: Lint
command: npm run lint
command: npm run lint:ci

integration_tests:
working_directory: ~/nest
Expand Down
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

47 changes: 0 additions & 47 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(The MIT License)

Copyright (c) 2017-2024 Kamil Mysliwiec <https://kamilmysliwiec.com>
Copyright (c) 2017-2025 Kamil Mysliwiec <https://kamilmysliwiec.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
55 changes: 55 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: ['node_modules', '**/node_modules/**', '**/*.js', '**/*.d.ts'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.spec.json'],
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-vars': 'off',
"@typescript-eslint/no-misused-promises": [
"error",
{
"checksVoidReturn": false,
"checksConditionals": false
}
],
"@typescript-eslint/require-await": "off",
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/only-throw-error': 'off',
},
},
);
1 change: 1 addition & 0 deletions integration/auto-mock/test/bar.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as chaiAsPromised from 'chai-as-promised';
import * as sinon from 'sinon';
import { BarService } from '../src/bar.service';
import { FooService } from '../src/foo.service';

chai.use(chaiAsPromised);
const { expect } = chai;

Expand Down
4 changes: 3 additions & 1 deletion integration/auto-mock/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],
Expand All @@ -32,7 +33,8 @@
},
"include": [
"src/**/*",
"e2e/**/*"
"e2e/**/*",
"test/**/*"
],
"exclude": [
"node_modules",
Expand Down
10 changes: 6 additions & 4 deletions integration/cors/e2e/fastify.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ describe.skip('Fastify Cors', () => {
);

let requestId = 0;
const configDelegation = function (req, cb) {
const config = configs[requestId];
requestId++;
cb(null, config);
const configDelegation = {
delegator: function (req, cb) {
const config = configs[requestId];
requestId++;
cb(null, config);
},
};
app.enableCors(configDelegation);

Expand Down
1 change: 1 addition & 0 deletions integration/cors/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],
Expand Down
6 changes: 3 additions & 3 deletions integration/discovery/src/webhooks.explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export class WebhooksExplorer {
const { name } = this.discoveryService.getMetadataByDecorator(
Webhook,
wrapper,
);
)!;
return {
name,
handlers: this.metadataScanner
.getAllMethodNames(wrapper.metatype.prototype)
.getAllMethodNames(wrapper.metatype!.prototype)
.map(methodName => {
const { event } = this.discoveryService.getMetadataByDecorator(
WebhookHandler,
wrapper,
methodName,
);
)!;
return {
methodName,
event,
Expand Down
1 change: 1 addition & 0 deletions integration/discovery/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],
Expand Down
1 change: 1 addition & 0 deletions integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
mysql:
image: mysql:9.1.0
environment:
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
ports:
Expand Down
2 changes: 1 addition & 1 deletion integration/graphql-code-first/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ async function bootstrap() {
app.useGlobalPipes(new ValidationPipe());
await app.listen(3000);
}
bootstrap();
void bootstrap();
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class RecipesResolver {
@Args('newRecipeData') newRecipeData: NewRecipeInput,
): Promise<Recipe> {
const recipe = await this.recipesService.create(newRecipeData);
pubSub.publish('recipeAdded', { recipeAdded: recipe });
void pubSub.publish('recipeAdded', { recipeAdded: recipe });
return recipe;
}

Expand Down
1 change: 1 addition & 0 deletions integration/graphql-code-first/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('GraphQL request scoped', () => {
],
},
})
.end((err, res) => {
.end(err => {
if (err) return end(err);
end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export class CatsRequestScopedService {
}

findOneById(id: number): Cat {
return this.cats.find(cat => cat.id === id);
return this.cats.find(cat => cat.id === id)!;
}
}
4 changes: 2 additions & 2 deletions integration/graphql-schema-first/src/cats/cats.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class CatsResolvers {

@Mutation('createCat')
async create(@Args() args: Cat): Promise<Cat> {
const createdCat = await this.catsService.create(args);
pubSub.publish('catCreated', { catCreated: createdCat });
const createdCat = this.catsService.create(args);
void pubSub.publish('catCreated', { catCreated: createdCat });
return createdCat;
}

Expand Down
2 changes: 1 addition & 1 deletion integration/graphql-schema-first/src/cats/cats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export class CatsService {
}

findOneById(id: number): Cat {
return this.cats.find(cat => cat.id === id);
return this.cats.find(cat => cat.id === id)!;
}
}
2 changes: 1 addition & 1 deletion integration/graphql-schema-first/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(3000);
}
bootstrap();
void bootstrap();
1 change: 1 addition & 0 deletions integration/graphql-schema-first/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"target": "ES2021",
"sourceMap": true,
"allowJs": true,
"strictNullChecks": true,
"outDir": "./dist",
"paths": {
"@nestjs/common": ["../../packages/common"],
Expand Down
37 changes: 33 additions & 4 deletions integration/hello-world/e2e/exclude-middleware-fastify.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ class TestController {
return RETURN_VALUE;
}

@Get('legacy-wildcard/overview')
testLegacyWildcard() {
return RETURN_VALUE;
}

@Get('splat-wildcard/overview')
testSplatWildcard() {
return RETURN_VALUE;
}

@Get('overview/:id')
overviewById() {
return RETURN_VALUE;
Expand All @@ -64,10 +74,17 @@ class TestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply((req, res, next) => res.end(MIDDLEWARE_VALUE))
.exclude('test', 'overview/:id', 'wildcard/(.*)', {
path: 'middleware',
method: RequestMethod.POST,
})
.exclude(
'test',
'overview/:id',
'wildcard/*',
'legacy-wildcard/(.*)',
'splat-wildcard/*splat',
{
path: 'middleware',
method: RequestMethod.POST,
},
)
.forRoutes('*');
}
}
Expand Down Expand Up @@ -126,6 +143,18 @@ describe('Exclude middleware (fastify)', () => {
.expect(200, RETURN_VALUE);
});

it(`should exclude "/legacy-wildcard/overview" endpoint (by wildcard, legacy syntax)`, () => {
return request(app.getHttpServer())
.get('/legacy-wildcard/overview')
.expect(200, RETURN_VALUE);
});

it(`should exclude "/splat-wildcard/overview" endpoint (by wildcard, new syntax)`, () => {
return request(app.getHttpServer())
.get('/splat-wildcard/overview')
.expect(200, RETURN_VALUE);
});

afterEach(async () => {
await app.close();
});
Expand Down
Loading

0 comments on commit 09d5963

Please sign in to comment.