mirror of
https://github.com/nestjs/nest.git
synced 2026-10-28 09:45:43 +08:00
build: migrate from cjs to esm
This commit is contained in:
1120 files changed
+5398
-4232
No files matched your search
+24
-58
@@ -1,12 +1,6 @@
|
||||
version: 2.1
|
||||
|
||||
parameters:
|
||||
check-legacy-node-version:
|
||||
type: boolean
|
||||
default: false
|
||||
legacy-node-version:
|
||||
type: string
|
||||
default: '18.20'
|
||||
maintenance-node-version:
|
||||
type: string
|
||||
default: '20.18'
|
||||
@@ -15,7 +9,7 @@ parameters:
|
||||
default: '22.11'
|
||||
current-node-version:
|
||||
type: string
|
||||
default: '23.3'
|
||||
default: '24.1'
|
||||
|
||||
aliases:
|
||||
- &restore-cache
|
||||
@@ -62,61 +56,36 @@ jobs:
|
||||
docker:
|
||||
- image: cimg/node:<< parameters.node-version >>
|
||||
steps:
|
||||
- checkout
|
||||
- *restore-cache
|
||||
- *install-deps
|
||||
- *build-packages
|
||||
- when:
|
||||
condition:
|
||||
and:
|
||||
- equal:
|
||||
[
|
||||
'<< parameters.node-version >>',
|
||||
'<< pipeline.parameters.legacy-node-version >>',
|
||||
]
|
||||
- not: << pipeline.parameters.check-legacy-node-version >>
|
||||
equal:
|
||||
[
|
||||
'<< parameters.node-version >>',
|
||||
'<< pipeline.parameters.maintenance-node-version >>',
|
||||
]
|
||||
steps:
|
||||
- run:
|
||||
name: Skip
|
||||
command: |
|
||||
echo Skipping
|
||||
name: Test (coverage)
|
||||
command: npm run test:cov
|
||||
- run:
|
||||
name: Collect coverage
|
||||
command: npm run coverage
|
||||
- store_artifacts:
|
||||
path: coverage
|
||||
- when:
|
||||
condition:
|
||||
or:
|
||||
- not:
|
||||
equal:
|
||||
[
|
||||
'<< parameters.node-version >>',
|
||||
'<< pipeline.parameters.legacy-node-version >>',
|
||||
]
|
||||
- << pipeline.parameters.check-legacy-node-version >>
|
||||
not:
|
||||
equal:
|
||||
[
|
||||
'<< parameters.node-version >>',
|
||||
'<< pipeline.parameters.maintenance-node-version >>',
|
||||
]
|
||||
steps:
|
||||
- checkout
|
||||
- *restore-cache
|
||||
- *install-deps
|
||||
- *build-packages
|
||||
- when:
|
||||
condition:
|
||||
equal:
|
||||
[
|
||||
'<< parameters.node-version >>',
|
||||
'<< pipeline.parameters.maintenance-node-version >>',
|
||||
]
|
||||
steps:
|
||||
- run:
|
||||
name: Test (coverage)
|
||||
command: npm run test:cov
|
||||
- run:
|
||||
name: Collect coverage
|
||||
command: npm run coverage
|
||||
- store_artifacts:
|
||||
path: coverage
|
||||
- when:
|
||||
condition:
|
||||
not:
|
||||
equal:
|
||||
[
|
||||
'<< parameters.node-version >>',
|
||||
'<< pipeline.parameters.maintenance-node-version >>',
|
||||
]
|
||||
steps:
|
||||
- *run-unit-tests
|
||||
- *run-unit-tests
|
||||
|
||||
lint:
|
||||
working_directory: ~/nest
|
||||
@@ -183,7 +152,6 @@ jobs:
|
||||
name: Build all samples
|
||||
command: npm run build:samples
|
||||
|
||||
|
||||
workflows:
|
||||
build-and-test:
|
||||
jobs:
|
||||
@@ -195,7 +163,6 @@ workflows:
|
||||
parameters:
|
||||
node-version:
|
||||
[
|
||||
'<< pipeline.parameters.legacy-node-version >>',
|
||||
'<< pipeline.parameters.maintenance-node-version >>',
|
||||
'<< pipeline.parameters.active-node-version >>',
|
||||
'<< pipeline.parameters.current-node-version >>',
|
||||
@@ -209,4 +176,3 @@ workflows:
|
||||
- samples:
|
||||
requires:
|
||||
- build
|
||||
|
||||
+3
-2
@@ -116,7 +116,6 @@ We cannot accept code without this.
|
||||
1. In GitHub, send a pull request to `nestjs:master`.
|
||||
|
||||
- If we suggest changes then:
|
||||
|
||||
- Make the required updates.
|
||||
- Re-run the Nest test suites to ensure tests are still passing.
|
||||
- Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
|
||||
@@ -159,7 +158,7 @@ from the main (upstream) repository:
|
||||
|
||||
## <a name="development"></a> Development Setup
|
||||
|
||||
You will need [Node.js](https://nodejs.org) version >= 10.13.0 (except for v13).
|
||||
You will need [Node.js](https://nodejs.org) version >= 20.
|
||||
|
||||
1. After cloning the repo, run:
|
||||
|
||||
@@ -322,8 +321,10 @@ changes to be accepted, the CLA must be signed. It's a quick process, we promise
|
||||
<!-- [coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md -->
|
||||
|
||||
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
|
||||
|
||||
<!-- [individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html -->
|
||||
<!-- [corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html -->
|
||||
|
||||
[dev-doc]: https://github.com/nestjs/nest/blob/master/docs/DEVELOPER.md
|
||||
[github]: https://github.com/nestjs/nest
|
||||
[stackoverflow]: https://stackoverflow.com/questions/tagged/nestjs
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
'use strict';
|
||||
/**
|
||||
* Load the TypeScript compiler, then load the TypeScript gulpfile which simply loads all
|
||||
* the tasks. The tasks are really inside tools/gulp/tasks.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const projectDir = __dirname;
|
||||
const tsconfigPath = path.join(projectDir, 'tools/gulp/tsconfig.json');
|
||||
|
||||
require('ts-node').register({
|
||||
project: tsconfigPath
|
||||
});
|
||||
|
||||
require('./tools/gulp/gulpfile');
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Load the TypeScript compiler, then load the TypeScript gulpfile which simply loads all
|
||||
* the tasks. The tasks are really inside tools/gulp/tasks.
|
||||
*/
|
||||
|
||||
import { register } from 'node:module';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
register('ts-node/esm', pathToFileURL('./'), {
|
||||
data: { project: './tools/gulp/tsconfig.json' },
|
||||
});
|
||||
|
||||
await import('./tools/gulp/gulpfile.ts');
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Registers ts-node's ESM loader hooks via the modern node:module register() API.
|
||||
* Used with --import flag (e.g., node --import ./hooks/ts-node-register.mjs)
|
||||
* to replace the deprecated --loader flag.
|
||||
*/
|
||||
import { register } from 'node:module';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
register('ts-node/esm', pathToFileURL('./'));
|
||||
|
||||
// Load reflect-metadata before any test files so decorators work correctly
|
||||
import 'reflect-metadata';
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { FooService } from './foo.service';
|
||||
import { FooService } from './foo.service.js';
|
||||
|
||||
@Injectable()
|
||||
export class BarService {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as chai from 'chai';
|
||||
import * as chaiAsPromised from 'chai-as-promised';
|
||||
import chai from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import * as sinon from 'sinon';
|
||||
import { BarService } from '../src/bar.service';
|
||||
import { FooService } from '../src/foo.service';
|
||||
import { BarService } from '../src/bar.service.js';
|
||||
import { FooService } from '../src/foo.service.js';
|
||||
|
||||
chai.use(chaiAsPromised);
|
||||
const { expect } = chai;
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('Express Cors', () => {
|
||||
let app: NestExpressApplication;
|
||||
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
NestFastifyApplication,
|
||||
} from '@nestjs/platform-fastify';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe.skip('Fastify Cors', () => {
|
||||
let app: NestFastifyApplication;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppController } from './app.controller.js';
|
||||
|
||||
@Module({
|
||||
controllers: [AppController],
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { DiscoveryService } from '@nestjs/core';
|
||||
import { expect } from 'chai';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { WebhooksExplorer } from '../src/webhooks.explorer';
|
||||
import { NonAppliedDecorator } from '../src/decorators/non-applied.decorator';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
import { WebhooksExplorer } from '../src/webhooks.explorer.js';
|
||||
import { NonAppliedDecorator } from '../src/decorators/non-applied.decorator.js';
|
||||
|
||||
describe('DiscoveryModule', () => {
|
||||
let moduleRef: TestingModule;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { DiscoveryModule } from '@nestjs/core';
|
||||
import { MyWebhookModule } from './my-webhook/my-webhook.module';
|
||||
import { WebhooksExplorer } from './webhooks.explorer';
|
||||
import { MyWebhookModule } from './my-webhook/my-webhook.module.js';
|
||||
import { WebhooksExplorer } from './webhooks.explorer.js';
|
||||
|
||||
@Module({
|
||||
imports: [MyWebhookModule, DiscoveryModule],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Webhook, WebhookHandler } from '../decorators/webhook.decorators';
|
||||
import { Webhook, WebhookHandler } from '../decorators/webhook.decorators.js';
|
||||
|
||||
@Webhook({ name: 'cleanup' })
|
||||
export class CleanupWebhook {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Webhook, WebhookHandler } from '../decorators/webhook.decorators';
|
||||
import { Webhook, WebhookHandler } from '../decorators/webhook.decorators.js';
|
||||
|
||||
@Webhook({ name: 'flush' })
|
||||
export class FlushWebhook {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CleanupWebhook } from './cleanup.webhook';
|
||||
import { FlushWebhook } from './flush.webhook';
|
||||
import { CleanupWebhook } from './cleanup.webhook.js';
|
||||
import { FlushWebhook } from './flush.webhook.js';
|
||||
|
||||
@Module({ providers: [CleanupWebhook, FlushWebhook] })
|
||||
export class MyWebhookModule {}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
||||
import { Webhook, WebhookHandler } from './decorators/webhook.decorators';
|
||||
import { Webhook, WebhookHandler } from './decorators/webhook.decorators.js';
|
||||
|
||||
@Injectable()
|
||||
export class WebhooksExplorer {
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('GraphQL - Code-first', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('GraphQL - Guards', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INestApplication, ValidationPipe } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('GraphQL Pipes', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { join } from 'path';
|
||||
import { RecipesModule } from './recipes/recipes.module';
|
||||
import { RecipesModule } from './recipes/recipes.module.js';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { AppModule } from './app.module.js';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { APP_FILTER } from '@nestjs/core';
|
||||
import { UnauthorizedFilter } from '../common/filters/unauthorized.filter';
|
||||
import { DateScalar } from '../common/scalars/date.scalar';
|
||||
import { RecipesResolver } from './recipes.resolver';
|
||||
import { RecipesService } from './recipes.service';
|
||||
import { UnauthorizedFilter } from '../common/filters/unauthorized.filter.js';
|
||||
import { DateScalar } from '../common/scalars/date.scalar.js';
|
||||
import { RecipesResolver } from './recipes.resolver.js';
|
||||
import { RecipesService } from './recipes.service.js';
|
||||
|
||||
@Module({
|
||||
providers: [
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { NotFoundException, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||
import { Args, Mutation, Query, Resolver, Subscription } from '@nestjs/graphql';
|
||||
import { PubSub } from 'graphql-subscriptions';
|
||||
import { AuthGuard } from '../common/guards/auth.guard';
|
||||
import { DataInterceptor } from '../common/interceptors/data.interceptor';
|
||||
import { NewRecipeInput } from './dto/new-recipe.input';
|
||||
import { RecipesArgs } from './dto/recipes.args';
|
||||
import { Recipe } from './models/recipe';
|
||||
import { RecipesService } from './recipes.service';
|
||||
import { AuthGuard } from '../common/guards/auth.guard.js';
|
||||
import { DataInterceptor } from '../common/interceptors/data.interceptor.js';
|
||||
import { NewRecipeInput } from './dto/new-recipe.input.js';
|
||||
import { RecipesArgs } from './dto/recipes.args.js';
|
||||
import { Recipe } from './models/recipe.js';
|
||||
import { RecipesService } from './recipes.service.js';
|
||||
|
||||
const pubSub = new PubSub();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { NewRecipeInput } from './dto/new-recipe.input';
|
||||
import { RecipesArgs } from './dto/recipes.args';
|
||||
import { Recipe } from './models/recipe';
|
||||
import { NewRecipeInput } from './dto/new-recipe.input.js';
|
||||
import { RecipesArgs } from './dto/recipes.args.js';
|
||||
import { Recipe } from './models/recipe.js';
|
||||
|
||||
@Injectable()
|
||||
export class RecipesService {
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncClassApplicationModule } from '../src/async-options-class.module';
|
||||
import request from 'supertest';
|
||||
import { AsyncClassApplicationModule } from '../src/async-options-class.module.js';
|
||||
|
||||
describe('GraphQL (async class)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncExistingApplicationModule } from '../src/async-options-existing.module';
|
||||
import request from 'supertest';
|
||||
import { AsyncExistingApplicationModule } from '../src/async-options-existing.module.js';
|
||||
|
||||
describe('GraphQL (async existing)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import * as request from 'supertest';
|
||||
import { AsyncApplicationModule } from '../src/async-options.module';
|
||||
import request from 'supertest';
|
||||
import { AsyncApplicationModule } from '../src/async-options.module.js';
|
||||
|
||||
describe('GraphQL (async configuration)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
@@ -4,9 +4,9 @@ import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { join } from 'path';
|
||||
import * as request from 'supertest';
|
||||
import { CatsRequestScopedService } from '../src/cats/cats-request-scoped.service';
|
||||
import { CatsModule } from '../src/cats/cats.module';
|
||||
import request from 'supertest';
|
||||
import { CatsRequestScopedService } from '../src/cats/cats-request-scoped.service.js';
|
||||
import { CatsModule } from '../src/cats/cats.module.js';
|
||||
|
||||
describe('GraphQL request scoped', () => {
|
||||
let app: INestApplication;
|
||||
@@ -17,7 +17,9 @@ describe('GraphQL request scoped', () => {
|
||||
CatsModule.enableRequestScope(),
|
||||
GraphQLModule.forRoot({
|
||||
driver: ApolloDriver,
|
||||
typePaths: [join(__dirname, '..', 'src', '**', '*.graphql')],
|
||||
typePaths: [
|
||||
join(import.meta.dirname, '..', 'src', '**', '*.graphql'),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}).compile();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('GraphQL', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { join } from 'path';
|
||||
import { CatsModule } from './cats/cats.module';
|
||||
import { CatsModule } from './cats/cats.module.js';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -10,7 +10,7 @@ import { CatsModule } from './cats/cats.module';
|
||||
GraphQLModule.forRoot<ApolloDriverConfig>({
|
||||
driver: ApolloDriver,
|
||||
includeStacktraceInErrorResponses: true,
|
||||
typePaths: [join(__dirname, '**', '*.graphql')],
|
||||
typePaths: [join(import.meta.dirname, '**', '*.graphql')],
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
@@ -2,12 +2,12 @@ import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { GqlOptionsFactory, GraphQLModule } from '@nestjs/graphql';
|
||||
import { join } from 'path';
|
||||
import { CatsModule } from './cats/cats.module';
|
||||
import { CatsModule } from './cats/cats.module.js';
|
||||
|
||||
class ConfigService implements GqlOptionsFactory {
|
||||
createGqlOptions(): ApolloDriverConfig {
|
||||
return {
|
||||
typePaths: [join(__dirname, '**', '*.graphql')],
|
||||
typePaths: [join(import.meta.dirname, '**', '*.graphql')],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { CatsModule } from './cats/cats.module';
|
||||
import { ConfigModule } from './config.module';
|
||||
import { ConfigService } from './config.service';
|
||||
import { CatsModule } from './cats/cats.module.js';
|
||||
import { ConfigModule } from './config.module.js';
|
||||
import { ConfigService } from './config.service.js';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { join } from 'path';
|
||||
import { CatsModule } from './cats/cats.module';
|
||||
import { CatsModule } from './cats/cats.module.js';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -10,7 +10,7 @@ import { CatsModule } from './cats/cats.module';
|
||||
GraphQLModule.forRootAsync<ApolloDriverConfig>({
|
||||
driver: ApolloDriver,
|
||||
useFactory: async () => ({
|
||||
typePaths: [join(__dirname, '**', '*.graphql')],
|
||||
typePaths: [join(import.meta.dirname, '**', '*.graphql')],
|
||||
}),
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, Scope } from '@nestjs/common';
|
||||
import { Cat } from './interfaces/cat.interface';
|
||||
import { Cat } from './interfaces/cat.interface.js';
|
||||
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class CatsRequestScopedService {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DynamicModule, Module, Scope } from '@nestjs/common';
|
||||
import { CatsRequestScopedService } from './cats-request-scoped.service';
|
||||
import { CatsResolvers } from './cats.resolvers';
|
||||
import { CatsService } from './cats.service';
|
||||
import { CatsRequestScopedService } from './cats-request-scoped.service.js';
|
||||
import { CatsResolvers } from './cats.resolvers.js';
|
||||
import { CatsService } from './cats.service.js';
|
||||
|
||||
@Module({
|
||||
providers: [CatsService, CatsResolvers],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ParseIntPipe, UseGuards } from '@nestjs/common';
|
||||
import { Args, Mutation, Query, Resolver, Subscription } from '@nestjs/graphql';
|
||||
import { PubSub } from 'graphql-subscriptions';
|
||||
import { CatsGuard } from './cats.guard';
|
||||
import { CatsService } from './cats.service';
|
||||
import { Cat } from './interfaces/cat.interface';
|
||||
import { CatsGuard } from './cats.guard.js';
|
||||
import { CatsService } from './cats.service.js';
|
||||
import { Cat } from './interfaces/cat.interface.js';
|
||||
|
||||
const pubSub = new PubSub();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Cat } from './interfaces/cat.interface';
|
||||
import { Cat } from './interfaces/cat.interface.js';
|
||||
|
||||
@Injectable()
|
||||
export class CatsService {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigService } from './config.service';
|
||||
import { ConfigService } from './config.service.js';
|
||||
|
||||
@Module({
|
||||
providers: [ConfigService],
|
||||
|
||||
@@ -6,7 +6,7 @@ import { join } from 'path';
|
||||
export class ConfigService implements GqlOptionsFactory {
|
||||
createGqlOptions(): GqlModuleOptions {
|
||||
return {
|
||||
typePaths: [join(__dirname, '**', '*.graphql')],
|
||||
typePaths: [join(import.meta.dirname, '**', '*.graphql')],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { AppModule } from './app.module.js';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { RawServerDefault } from 'fastify';
|
||||
import * as request from 'supertest';
|
||||
import { ErrorsController } from '../src/errors/errors.controller';
|
||||
import request from 'supertest';
|
||||
import { ErrorsController } from '../src/errors/errors.controller.js';
|
||||
|
||||
describe('Error messages', () => {
|
||||
let server: RawServerDefault;
|
||||
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
NestFastifyApplication,
|
||||
} from '@nestjs/platform-fastify';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
const RETURN_VALUE = 'test';
|
||||
const MIDDLEWARE_VALUE = 'middleware';
|
||||
|
||||
@@ -8,8 +8,8 @@ import {
|
||||
RequestMethod,
|
||||
} from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
const RETURN_VALUE = 'test';
|
||||
const MIDDLEWARE_VALUE = 'middleware';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { ExpressAdapter } from '@nestjs/platform-express';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as express from 'express';
|
||||
import * as request from 'supertest';
|
||||
import express from 'express';
|
||||
import request from 'supertest';
|
||||
import { App } from 'supertest/types';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('Hello world (express instance)', () => {
|
||||
let server: App;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { ExpressAdapter } from '@nestjs/platform-express';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as express from 'express';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import express from 'express';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('Hello world (express instance with multiple applications)', () => {
|
||||
let server;
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
} from '@nestjs/platform-fastify';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('Hello world (fastify adapter)', () => {
|
||||
let app: NestFastifyApplication;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { ApplicationModule } from '../src/app.module';
|
||||
import { ApplicationModule } from '../src/app.module.js';
|
||||
|
||||
describe('Hello world (fastify adapter with multiple applications)', () => {
|
||||
let adapter: FastifyAdapter;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ConsoleLogger, INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
import * as sinon from 'sinon';
|
||||
import { expect } from 'chai';
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
@Injectable()
|
||||
export class AuthGuard {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as request from 'supertest';
|
||||
import request from 'supertest';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('Hello world (default adapter)', () => {
|
||||
let server;
|
||||
|
||||
@@ -9,8 +9,8 @@ import { APP_INTERCEPTOR } from '@nestjs/core';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
const RETURN_VALUE = 'test';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('Hello world (default adapter)', () => {
|
||||
let server;
|
||||
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { Response } from 'express';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
const INCLUDED_VALUE = 'test_included';
|
||||
const RETURN_VALUE = 'test';
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
Module,
|
||||
} from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import request from 'supertest';
|
||||
|
||||
const RETURN_VALUE_A = 'test_A';
|
||||
const RETURN_VALUE_B = 'test_B';
|
||||
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { FastifyRequest } from 'fastify';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
describe('Middleware (FastifyAdapter)', () => {
|
||||
let app: NestFastifyApplication;
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
NestMiddleware,
|
||||
Module,
|
||||
} from '@nestjs/common';
|
||||
import { Test } from '../../../packages/testing';
|
||||
import * as request from 'supertest';
|
||||
import { Test } from '../../../packages/testing.js';
|
||||
import request from 'supertest';
|
||||
import { expect } from 'chai';
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,14 +6,14 @@ import {
|
||||
Module,
|
||||
RequestMethod,
|
||||
Version,
|
||||
VERSION_NEUTRAL,
|
||||
VersioningOptions,
|
||||
VersioningType,
|
||||
VERSION_NEUTRAL,
|
||||
} from '@nestjs/common';
|
||||
import { CustomVersioningOptions } from '@nestjs/common/interfaces';
|
||||
import { CustomVersioningOptions } from '@nestjs/common/interfaces/index.js';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
const RETURN_VALUE = 'test';
|
||||
const VERSIONED_VALUE = 'test_versioned';
|
||||
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
Module,
|
||||
} from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
const RETURN_VALUE = 'test';
|
||||
const SCOPED_VALUE = 'test_scoped';
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { RouterModule } from '@nestjs/core';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import request from 'supertest';
|
||||
import { AppModule } from '../src/app.module.js';
|
||||
|
||||
const RETURN_VALUE = 'test';
|
||||
const SCOPED_VALUE = 'test_scoped';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Controller, Get, INestApplication, Module } from '@nestjs/common';
|
||||
import { RouterModule, Routes } from '@nestjs/core';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import request from 'supertest';
|
||||
|
||||
describe('RouterModule', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { HelloModule } from './hello/hello.module';
|
||||
import { HostArrayModule } from './host-array/host-array.module';
|
||||
import { HostModule } from './host/host.module';
|
||||
import { HelloModule } from './hello/hello.module.js';
|
||||
import { HostArrayModule } from './host-array/host-array.module.js';
|
||||
import { HostModule } from './host/host.module.js';
|
||||
|
||||
@Module({
|
||||
imports: [HelloModule, HostModule, HostArrayModule],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Controller, Get, Header, Param } from '@nestjs/common';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { HelloService } from './hello.service';
|
||||
import { UserByIdPipe } from './users/user-by-id.pipe';
|
||||
import { HelloService } from './hello.service.js';
|
||||
import { UserByIdPipe } from './users/user-by-id.pipe.js';
|
||||
|
||||
@Controller('hello')
|
||||
export class HelloController {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { HelloController } from './hello.controller';
|
||||
import { HelloService } from './hello.service';
|
||||
import { UsersService } from './users/users.service';
|
||||
import { HelloController } from './hello.controller.js';
|
||||
import { HelloService } from './hello.service.js';
|
||||
import { UsersService } from './users/users.service.js';
|
||||
|
||||
@Module({
|
||||
controllers: [HelloController],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PipeTransform, Injectable, ArgumentMetadata } from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
import { UsersService } from './users.service.js';
|
||||
|
||||
@Injectable()
|
||||
export class UserByIdPipe implements PipeTransform<string> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Controller, Get, Header, HostParam, Param } from '@nestjs/common';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { HostArrayService } from './host-array.service';
|
||||
import { UserByIdPipe } from './users/user-by-id.pipe';
|
||||
import { HostArrayService } from './host-array.service.js';
|
||||
import { UserByIdPipe } from './users/user-by-id.pipe.js';
|
||||
|
||||
@Controller({
|
||||
path: 'host-array',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { HostArrayController } from './host-array.controller';
|
||||
import { HostArrayService } from './host-array.service';
|
||||
import { UsersService } from './users/users.service';
|
||||
import { HostArrayController } from './host-array.controller.js';
|
||||
import { HostArrayService } from './host-array.service.js';
|
||||
import { UsersService } from './users/users.service.js';
|
||||
|
||||
@Module({
|
||||
controllers: [HostArrayController],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PipeTransform, Injectable, ArgumentMetadata } from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
import { UsersService } from './users.service.js';
|
||||
|
||||
@Injectable()
|
||||
export class UserByIdPipe implements PipeTransform<string> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Controller, Get, Header, HostParam, Param } from '@nestjs/common';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { HostService } from './host.service';
|
||||
import { UserByIdPipe } from './users/user-by-id.pipe';
|
||||
import { HostService } from './host.service.js';
|
||||
import { UserByIdPipe } from './users/user-by-id.pipe.js';
|
||||
|
||||
@Controller({
|
||||
path: 'host',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { HostController } from './host.controller';
|
||||
import { HostService } from './host.service';
|
||||
import { UsersService } from './users/users.service';
|
||||
import { HostController } from './host.controller.js';
|
||||
import { HostService } from './host.service.js';
|
||||
import { UsersService } from './users/users.service.js';
|
||||
|
||||
@Module({
|
||||
controllers: [HostController],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PipeTransform, Injectable, ArgumentMetadata } from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
import { UsersService } from './users.service.js';
|
||||
|
||||
@Injectable()
|
||||
export class UserByIdPipe implements PipeTransform<string> {
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -2,12 +2,23 @@ import { expect } from 'chai';
|
||||
import { spawnSync } from 'child_process';
|
||||
import { join } from 'path';
|
||||
|
||||
// Use node with the ts-node ESM loader (same as mocha's --import)
|
||||
const nodeCmd = process.execPath;
|
||||
const loaderArgs = [
|
||||
'--import',
|
||||
join(import.meta.dirname, '../../../hooks/ts-node-register.mjs'),
|
||||
];
|
||||
|
||||
function spawnTsNode(...args: string[]) {
|
||||
return spawnSync(nodeCmd, [...loaderArgs, ...args]);
|
||||
}
|
||||
|
||||
describe('enableShutdownHooks', () => {
|
||||
it('should call the correct hooks if any shutdown signal gets invoked', done => {
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
const result = spawnTsNode(
|
||||
join(import.meta.dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
'SIGHUP',
|
||||
]);
|
||||
);
|
||||
const calls = result.stdout
|
||||
.toString()
|
||||
.split('\n')
|
||||
@@ -18,11 +29,11 @@ describe('enableShutdownHooks', () => {
|
||||
}).timeout(10000);
|
||||
|
||||
it('should call the correct hooks if a specific shutdown signal gets invoked', done => {
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
const result = spawnTsNode(
|
||||
join(import.meta.dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
'SIGINT',
|
||||
'SIGINT',
|
||||
]);
|
||||
);
|
||||
const calls = result.stdout
|
||||
.toString()
|
||||
.split('\n')
|
||||
@@ -33,32 +44,32 @@ describe('enableShutdownHooks', () => {
|
||||
}).timeout(10000);
|
||||
|
||||
it('should ignore system signals which are not specified', done => {
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
const result = spawnTsNode(
|
||||
join(import.meta.dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
'SIGINT',
|
||||
'SIGHUP',
|
||||
]);
|
||||
);
|
||||
expect(result.stdout.toString().trim()).to.be.eq('');
|
||||
done();
|
||||
}).timeout(10000);
|
||||
|
||||
it('should ignore system signals if "enableShutdownHooks" was not called', done => {
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
const result = spawnTsNode(
|
||||
join(import.meta.dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
'SIGINT',
|
||||
'NONE',
|
||||
]);
|
||||
);
|
||||
expect(result.stdout.toString().trim()).to.be.eq('');
|
||||
done();
|
||||
}).timeout(10000);
|
||||
|
||||
it('should call the correct hooks with useProcessExit option', done => {
|
||||
const result = spawnSync('ts-node', [
|
||||
join(__dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
const result = spawnTsNode(
|
||||
join(import.meta.dirname, '../src/enable-shutdown-hooks-main.ts'),
|
||||
'SIGHUP',
|
||||
'SIGHUP',
|
||||
'graceful',
|
||||
]);
|
||||
);
|
||||
const calls = result.stdout
|
||||
.toString()
|
||||
.split('\n')
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"esModuleInterop": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"target": "ES2023",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { CircularModule } from '../src/circular-modules/circular.module';
|
||||
import { CircularService } from '../src/circular-modules/circular.service';
|
||||
import { InputModule } from '../src/circular-modules/input.module';
|
||||
import { InputService } from '../src/circular-modules/input.service';
|
||||
import { CircularModule } from '../src/circular-modules/circular.module.js';
|
||||
import { CircularService } from '../src/circular-modules/circular.service.js';
|
||||
import { InputModule } from '../src/circular-modules/input.module.js';
|
||||
import { InputService } from '../src/circular-modules/input.service.js';
|
||||
|
||||
describe('Circular dependency (modules)', () => {
|
||||
it('should resolve circular dependency between providers', async () => {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { CircularPropertiesModule } from '../src/circular-properties/circular-properties.module';
|
||||
import { CircularService } from '../src/circular-properties/circular.service';
|
||||
import { InputPropertiesModule } from '../src/circular-properties/input-properties.module';
|
||||
import { InputService } from '../src/circular-properties/input.service';
|
||||
import { CircularPropertiesModule } from '../src/circular-properties/circular-properties.module.js';
|
||||
import { CircularService } from '../src/circular-properties/circular.service.js';
|
||||
import { InputPropertiesModule } from '../src/circular-properties/input-properties.module.js';
|
||||
import { InputService } from '../src/circular-properties/input.service.js';
|
||||
|
||||
describe('Circular properties dependency (modules)', () => {
|
||||
it('should resolve circular dependency between providers', async () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { expect } from 'chai';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { CircularModule } from '../src/circular-structure-dynamic-module/circular.module';
|
||||
import { InputService } from '../src/circular-structure-dynamic-module/input.service';
|
||||
import { CircularModule } from '../src/circular-structure-dynamic-module/circular.module.js';
|
||||
import { InputService } from '../src/circular-structure-dynamic-module/input.service.js';
|
||||
|
||||
describe('Circular structure for dynamic modules', () => {
|
||||
it('should resolve circular structure with dynamic modules', async () => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { CircularModule } from '../src/circular/circular.module';
|
||||
import { CircularService } from '../src/circular/circular.service';
|
||||
import { InputService } from '../src/circular/input.service';
|
||||
import { CircularModule } from '../src/circular/circular.module.js';
|
||||
import { CircularService } from '../src/circular/circular.service.js';
|
||||
import { InputService } from '../src/circular/input.service.js';
|
||||
|
||||
describe('Circular dependency', () => {
|
||||
it('should resolve circular dependency between providers', async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { CoreInjectablesModule } from '../src/core-injectables/core-injectables.module';
|
||||
import { CoreInjectablesModule } from '../src/core-injectables/core-injectables.module.js';
|
||||
import { ApplicationConfig, ModuleRef } from '@nestjs/core';
|
||||
|
||||
describe('Core Injectables', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { DefaultsModule } from '../src/defaults/defaults.module';
|
||||
import { DefaultsService } from '../src/defaults/defaults.service';
|
||||
import { DefaultsModule } from '../src/defaults/defaults.module.js';
|
||||
import { DefaultsService } from '../src/defaults/defaults.service.js';
|
||||
|
||||
describe('Injector', () => {
|
||||
describe('when optional', () => {
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
import { RuntimeException } from '@nestjs/core/errors/exceptions/runtime.exception';
|
||||
import { UnknownDependenciesException } from '@nestjs/core/errors/exceptions/unknown-dependencies.exception';
|
||||
import { UnknownExportException } from '@nestjs/core/errors/exceptions/unknown-export.exception';
|
||||
import { RuntimeException } from '@nestjs/core/errors/exceptions/runtime.exception.js';
|
||||
import { UnknownDependenciesException } from '@nestjs/core/errors/exceptions/unknown-dependencies.exception.js';
|
||||
import { UnknownExportException } from '@nestjs/core/errors/exceptions/unknown-export.exception.js';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import * as chai from 'chai';
|
||||
import * as chaiAsPromised from 'chai-as-promised';
|
||||
import chai, { expect } from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import {
|
||||
DYNAMIC_TOKEN,
|
||||
DYNAMIC_VALUE,
|
||||
NestDynamicModule,
|
||||
} from '../src/dynamic/dynamic.module';
|
||||
import { ExportsModule } from '../src/exports/exports.module';
|
||||
import { InjectModule } from '../src/inject/inject.module';
|
||||
import { InjectSameNameModule } from '../src/inject/inject-same-name.module';
|
||||
} from '../src/dynamic/dynamic.module.js';
|
||||
import { ExportsModule } from '../src/exports/exports.module.js';
|
||||
import { InjectSameNameModule } from '../src/inject/inject-same-name.module.js';
|
||||
import { InjectModule } from '../src/inject/inject.module.js';
|
||||
import {
|
||||
SelfInjectionProviderModule,
|
||||
SelfInjectionProviderCustomTokenModule,
|
||||
SelfInjectionForwardProviderModule,
|
||||
} from '../src/self-injection/self-injection-provider.module';
|
||||
SelfInjectionProviderCustomTokenModule,
|
||||
SelfInjectionProviderModule,
|
||||
} from '../src/self-injection/self-injection-provider.module.js';
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
describe('Injector', () => {
|
||||
|
||||
@@ -2,9 +2,9 @@ import { Scope } from '@nestjs/common';
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { ScopedModule, STATIC_FACTORY } from '../src/scoped/scoped.module';
|
||||
import { ScopedService } from '../src/scoped/scoped.service';
|
||||
import { TransientService } from '../src/scoped/transient.service';
|
||||
import { ScopedModule, STATIC_FACTORY } from '../src/scoped/scoped.module.js';
|
||||
import { ScopedService } from '../src/scoped/scoped.service.js';
|
||||
import { TransientService } from '../src/scoped/transient.service.js';
|
||||
|
||||
describe('Providers introspection', () => {
|
||||
let testingModule: TestingModule;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { MultipleProvidersModule } from '../src/multiple-providers/multiple-providers.module';
|
||||
import { MultipleProvidersModule } from '../src/multiple-providers/multiple-providers.module.js';
|
||||
|
||||
describe('Multiple providers under the same token ("each" feature)', () => {
|
||||
describe('get()', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Scope } from '@nestjs/common';
|
||||
import { UnknownDependenciesException } from '@nestjs/core/errors/exceptions/unknown-dependencies.exception';
|
||||
import { UnknownDependenciesException } from '@nestjs/core/errors/exceptions/unknown-dependencies.exception.js';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { UnknownDependenciesException } from '@nestjs/core/errors/exceptions/unknown-dependencies.exception.js';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { DependencyService } from '../src/properties/dependency.service';
|
||||
import { PropertiesModule } from '../src/properties/properties.module';
|
||||
import { PropertiesService } from '../src/properties/properties.service';
|
||||
import { UnknownDependenciesException } from '@nestjs/core/errors/exceptions/unknown-dependencies.exception';
|
||||
import { DependencyService } from '../src/properties/dependency.service.js';
|
||||
import { PropertiesModule } from '../src/properties/properties.module.js';
|
||||
import { PropertiesService } from '../src/properties/properties.service.js';
|
||||
|
||||
describe('Injector', () => {
|
||||
it('should resolve property-based dependencies', async () => {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { createContextId } from '@nestjs/core';
|
||||
import { InvalidClassScopeException } from '@nestjs/core/errors/exceptions/invalid-class-scope.exception';
|
||||
import { InvalidClassScopeException } from '@nestjs/core/errors/exceptions/invalid-class-scope.exception.js';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { ScopedController } from '../src/scoped/scoped.controller';
|
||||
import { ScopedController } from '../src/scoped/scoped.controller.js';
|
||||
import {
|
||||
REQUEST_SCOPED_FACTORY,
|
||||
ScopedModule,
|
||||
STATIC_FACTORY,
|
||||
TRANSIENT_SCOPED_FACTORY,
|
||||
} from '../src/scoped/scoped.module';
|
||||
import { ScopedService } from '../src/scoped/scoped.service';
|
||||
import { TransientService } from '../src/scoped/transient.service';
|
||||
import { Transient3Service } from '../src/scoped/transient3.service';
|
||||
} from '../src/scoped/scoped.module.js';
|
||||
import { ScopedService } from '../src/scoped/scoped.service.js';
|
||||
import { TransientService } from '../src/scoped/transient.service.js';
|
||||
import { Transient3Service } from '../src/scoped/transient3.service.js';
|
||||
|
||||
describe('Scoped Instances', () => {
|
||||
let testingModule: TestingModule;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ExportsModule } from './exports/exports.module';
|
||||
import { ExportsModule } from './exports/exports.module.js';
|
||||
|
||||
@Module({
|
||||
imports: [ExportsModule],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module, forwardRef } from '@nestjs/common';
|
||||
import { CircularService } from './circular.service';
|
||||
import { InputModule } from './input.module';
|
||||
import { CircularService } from './circular.service.js';
|
||||
import { InputModule } from './input.module.js';
|
||||
|
||||
@Module({
|
||||
imports: [forwardRef(() => InputModule)],
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { Injectable, forwardRef, Inject } from '@nestjs/common';
|
||||
import { InputService } from './input.service';
|
||||
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
||||
|
||||
// Use a lazy reference to avoid ESM circular-import TDZ issues
|
||||
// with emitDecoratorMetadata.
|
||||
let InputServiceRef: any;
|
||||
import('./input.service.js').then(m => (InputServiceRef = m.InputService));
|
||||
|
||||
@Injectable()
|
||||
export class CircularService {
|
||||
constructor(
|
||||
@Inject(forwardRef(() => InputService))
|
||||
public readonly service: InputService,
|
||||
@Inject(forwardRef(() => InputServiceRef))
|
||||
public readonly service: any,
|
||||
) {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Module, forwardRef } from '@nestjs/common';
|
||||
import { CircularModule } from './circular.module';
|
||||
import { InputService } from './input.service';
|
||||
import { CircularModule } from './circular.module.js';
|
||||
import { InputService } from './input.service.js';
|
||||
|
||||
@Module({
|
||||
imports: [forwardRef(() => CircularModule)],
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import { Injectable, Inject, forwardRef } from '@nestjs/common';
|
||||
import { CircularService } from './circular.service';
|
||||
import { Inject, Injectable, forwardRef } from '@nestjs/common';
|
||||
|
||||
// Use a lazy reference to avoid ESM circular-import TDZ issues
|
||||
// with emitDecoratorMetadata. The class is imported asynchronously
|
||||
// and cached for forwardRef resolution.
|
||||
let CircularServiceRef: any;
|
||||
import('./circular.service.js').then(
|
||||
m => (CircularServiceRef = m.CircularService),
|
||||
);
|
||||
|
||||
@Injectable()
|
||||
export class InputService {
|
||||
constructor(
|
||||
@Inject(forwardRef(() => CircularService))
|
||||
public readonly service: CircularService,
|
||||
@Inject(forwardRef(() => CircularServiceRef))
|
||||
public readonly service: any,
|
||||
) {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { forwardRef, Module } from '@nestjs/common';
|
||||
import { CircularService } from './circular.service';
|
||||
import { InputPropertiesModule } from './input-properties.module';
|
||||
import { CircularService } from './circular.service.js';
|
||||
import { InputPropertiesModule } from './input-properties.module.js';
|
||||
|
||||
@Module({
|
||||
imports: [forwardRef(() => InputPropertiesModule)],
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
||||
import { InputService } from './input.service';
|
||||
|
||||
// Lazy reference to avoid ESM circular-import TDZ issues
|
||||
// with emitDecoratorMetadata.
|
||||
let InputServiceRef: any;
|
||||
import('./input.service.js').then(m => (InputServiceRef = m.InputService));
|
||||
|
||||
@Injectable()
|
||||
export class CircularService {
|
||||
@Inject(forwardRef(() => InputService))
|
||||
public readonly service: InputService;
|
||||
@Inject(forwardRef(() => InputServiceRef))
|
||||
public readonly service: any;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { forwardRef, Module } from '@nestjs/common';
|
||||
import { CircularPropertiesModule } from './circular-properties.module';
|
||||
import { InputService } from './input.service';
|
||||
import { CircularPropertiesModule } from './circular-properties.module.js';
|
||||
import { InputService } from './input.service.js';
|
||||
|
||||
@Module({
|
||||
imports: [forwardRef(() => CircularPropertiesModule)],
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
||||
import { CircularService } from './circular.service';
|
||||
|
||||
// Lazy reference to avoid ESM circular-import TDZ issues
|
||||
// with emitDecoratorMetadata.
|
||||
let CircularServiceRef: any;
|
||||
import('./circular.service.js').then(
|
||||
m => (CircularServiceRef = m.CircularService),
|
||||
);
|
||||
|
||||
@Injectable()
|
||||
export class InputService {
|
||||
@Inject(forwardRef(() => CircularService))
|
||||
public readonly service: CircularService;
|
||||
@Inject(forwardRef(() => CircularServiceRef))
|
||||
public readonly service: any;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DynamicModule } from '@nestjs/common';
|
||||
import { InputService } from './input.service';
|
||||
import { InputService } from './input.service.js';
|
||||
|
||||
export class CircularModule {
|
||||
static forRoot(): DynamicModule {
|
||||
|
||||
Loaded 100 of 1120 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user