Skip to content

Commit

Permalink
Merge pull request #9588 from nestjs/9.0.0
Browse files Browse the repository at this point in the history
chore(): v9.0.0 release (wip)
  • Loading branch information
kamilmysliwiec authored Jul 7, 2022
2 parents 9108e41 + 5699161 commit 21bd8c3
Show file tree
Hide file tree
Showing 171 changed files with 5,168 additions and 2,959 deletions.
8 changes: 0 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ jobs:
- store_artifacts:
path: coverage

test_node_10:
<<: *unit-tests-template
docker:
- image: circleci/node:10

test_node_14:
<<: *unit-tests-template
docker:
Expand Down Expand Up @@ -174,9 +169,6 @@ workflows:
- test_node_12:
requires:
- build
- test_node_10:
requires:
- build
- lint:
requires:
- build
Expand Down
12 changes: 6 additions & 6 deletions integration/cors/e2e/express.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NestFastifyApplication } from '@nestjs/platform-fastify';
import { NestExpressApplication } from '@nestjs/platform-express';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';

describe('Express Cors', () => {
let app: NestFastifyApplication;
let app: NestExpressApplication;
const configs = [
{
origin: 'example.com',
Expand All @@ -30,7 +30,7 @@ describe('Express Cors', () => {
imports: [AppModule],
}).compile();

app = module.createNestApplication<NestFastifyApplication>();
app = module.createNestApplication<NestExpressApplication>();

let requestId = 0;
const configDelegation = function (req, cb) {
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('Express Cors', () => {
cb(null, config);
};

app = module.createNestApplication<NestFastifyApplication>(null, {
app = module.createNestApplication<NestExpressApplication>({
cors: configDelegation,
});

Expand Down Expand Up @@ -126,7 +126,7 @@ describe('Express Cors', () => {
imports: [AppModule],
}).compile();

app = module.createNestApplication<NestFastifyApplication>();
app = module.createNestApplication<NestExpressApplication>();
app.enableCors(configs[0]);

await app.init();
Expand All @@ -153,7 +153,7 @@ describe('Express Cors', () => {
imports: [AppModule],
}).compile();

app = module.createNestApplication<NestFastifyApplication>(null, {
app = module.createNestApplication<NestExpressApplication>({
cors: configs[0],
});
await app.init();
Expand Down
35 changes: 24 additions & 11 deletions integration/cors/e2e/fastify.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { NestFastifyApplication } from '@nestjs/platform-fastify';
import {
FastifyAdapter,
NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';

describe('Fastify Cors', () => {
describe.skip('Fastify Cors', () => {
let app: NestFastifyApplication;
const configs = [
{
Expand All @@ -30,7 +33,9 @@ describe('Fastify Cors', () => {
imports: [AppModule],
}).compile();

app = module.createNestApplication<NestFastifyApplication>();
app = module.createNestApplication<NestFastifyApplication>(
new FastifyAdapter(),
);

let requestId = 0;
const configDelegation = function (req, cb) {
Expand Down Expand Up @@ -84,9 +89,12 @@ describe('Fastify Cors', () => {
cb(null, config);
};

app = module.createNestApplication<NestFastifyApplication>(null, {
cors: configDelegation,
});
app = module.createNestApplication<NestFastifyApplication>(
new FastifyAdapter(),
{
cors: configDelegation,
},
);

await app.init();
});
Expand Down Expand Up @@ -127,7 +135,9 @@ describe('Fastify Cors', () => {
imports: [AppModule],
}).compile();

app = module.createNestApplication<NestFastifyApplication>();
app = module.createNestApplication<NestFastifyApplication>(
new FastifyAdapter(),
);
app.enableCors(configs[0]);

await app.init();
Expand All @@ -147,16 +157,19 @@ describe('Fastify Cors', () => {
after(async () => {
await app.close();
});

describe('Application Options', () => {
before(async () => {
const module = await Test.createTestingModule({
imports: [AppModule],
}).compile();

app = module.createNestApplication<NestFastifyApplication>(null, {
cors: configs[0],
});
app = module.createNestApplication<NestFastifyApplication>(
new FastifyAdapter(),
{
cors: configs[0],
},
);
await app.init();
});

Expand Down
2 changes: 1 addition & 1 deletion integration/microservices/e2e/disconnected-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Disconnected client', () => {
.send({
transport: Transport.REDIS,
options: {
url: 'redis://localhost:3333',
port: '3333',
},
})
.expect(408);
Expand Down
5 changes: 3 additions & 2 deletions integration/microservices/src/disconnected.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Controller,
InternalServerErrorException,
Post,
RequestTimeoutException,
RequestTimeoutException
} from '@nestjs/common';
import { ClientProxyFactory } from '@nestjs/microservices';
import { Observable, throwError } from 'rxjs';
Expand All @@ -24,7 +24,8 @@ export class DisconnectedClientController {
return throwError(() =>
code === 'ECONNREFUSED' ||
code === 'CONN_ERR' ||
code === 'CONNECTION_REFUSED'
code === 'CONNECTION_REFUSED' ||
error.message === 'Connection is closed.'
? new RequestTimeoutException('ECONNREFUSED')
: new InternalServerErrorException(),
);
Expand Down
17 changes: 17 additions & 0 deletions integration/module-utils/src/integration.module-definition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ConfigurableModuleBuilder } from '@nestjs/common';
import { IntegrationModuleOptions } from './interfaces/integration-module-options.interface';

export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } =
new ConfigurableModuleBuilder<IntegrationModuleOptions>()
.setClassMethodName('forRoot')
.setFactoryMethodName('construct')
.setExtras(
{
isGlobal: true,
},
(definition, extras) => ({
...definition,
global: extras.isGlobal,
}),
)
.build();
16 changes: 16 additions & 0 deletions integration/module-utils/src/integration.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Inject, Module } from '@nestjs/common';
import {
ConfigurableModuleClass,
MODULE_OPTIONS_TOKEN,
} from './integration.module-definition';
import { IntegrationModuleOptions } from './interfaces/integration-module-options.interface';

@Module({})
export class IntegrationModule extends ConfigurableModuleClass {
constructor(
@Inject(MODULE_OPTIONS_TOKEN)
public readonly options: IntegrationModuleOptions,
) {
super();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface IntegrationModuleOptions {
url: string;
secure?: boolean;
}
47 changes: 47 additions & 0 deletions integration/module-utils/test/integration-module.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Test } from '@nestjs/testing';
import { expect } from 'chai';
import { IntegrationModule } from '../src/integration.module';

describe('Module utils (ConfigurableModuleBuilder)', () => {
it('should auto-generate "forRoot" method', async () => {
const moduleRef = await Test.createTestingModule({
imports: [
IntegrationModule.forRoot({
isGlobal: true,
url: 'test_url',
secure: false,
}),
],
}).compile();

const integrationModule = moduleRef.get(IntegrationModule);

expect(integrationModule.options).to.deep.equal({
url: 'test_url',
secure: false,
});
});

it('should auto-generate "forRootAsync" method', async () => {
const moduleRef = await Test.createTestingModule({
imports: [
IntegrationModule.forRootAsync({
isGlobal: true,
useFactory: () => {
return {
url: 'test_url',
secure: false,
};
},
}),
],
}).compile();

const integrationModule = moduleRef.get(IntegrationModule);

expect(integrationModule.options).to.deep.equal({
url: 'test_url',
secure: false,
});
});
});
22 changes: 22 additions & 0 deletions integration/module-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"allowJs": true,
"outDir": "./dist"
},
"include": [
"src/**/*",
"e2e/**/*"
],
"exclude": [
"node_modules",
]
}
7 changes: 3 additions & 4 deletions integration/nest-application/raw-body/e2e/express.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ describe('Raw body (Express Application)', () => {
imports: [ExpressModule],
}).compile();

app = moduleFixture.createNestApplication<NestExpressApplication>(
undefined,
{ rawBody: true },
);
app = moduleFixture.createNestApplication<NestExpressApplication>({
rawBody: true,
});
});

it('should return exact post body', async () => {
Expand Down
Loading

0 comments on commit 21bd8c3

Please sign in to comment.