2.0.3 • Published 3 years ago

nestjs-scanloader v2.0.3

Weekly downloads
97
License
MIT
Repository
github
Last release
3 years ago

Description

Nest module for autoload providers and controllers.

Installation

$ npm install nestjs-scanloader

Example

import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { ScanLoaderModule } from 'nestjs-scanloader';

@Module({
    imports: [
        ScanLoaderModule.register({
            name: 'test',
            basePath: __dirname,
            controllersPaths: ['/controllers/**/*.controller.js'],
            providersPaths: ['/services/**/*.service.js'],
            imports: [JwtModule.register({})],
        }),
    ],
})
export class AppModule {}

Example using module decorator

import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { ScanModule } from 'nestjs-scanloader';


@ScanModule({
    basePath: __dirname,
    controllersPaths: ['/controllers/**/*.controller.*'],
    providersPaths: ['/services/**/*.service.*'],
    imports: [JwtModule.register({})],
})
export class AppModule {}

Register options

export interface ScanOptions {
    name: string;
    basePath: string;
    controllersPaths?: string[];
    providersPaths?: string[];
    imports?: Array<
        Type<any> | DynamicModule | Promise<DynamicModule> | ForwardReference
    >;
    ignores?: string[];
    providers?: Provider<any>[];
    export?: boolean;
}
  • name: identifier of current register for logs.
  • basePath: url root for controllersPaths and providersPaths.
  • controllersPaths: list of FastGlob expressions for match controllers.
  • providersPaths: list of FastGlob expressions for match providers.
  • imports: list of dependecies modules for autolad provides and controllers.
  • ignores: list of FastGlob expressions for ignore during scan.
  • export: if autoload providers need to be exported.

Module decorator options

Extends default metadata for Module Nest decorator

export interface IScanOptions {
    basePath: string;
    controllersPaths?: string[];
    providersPaths?: string[];
    ignores?: string[];
}
  • basePath: url root for controllersPaths and providersPaths.
  • controllersPaths: list of FastGlob expressions for match controllers.
  • providersPaths: list of FastGlob expressions for match providers.
  • ignores: list of FastGlob expressions for ignore during scan.

License

Nest is MIT licensed.

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.2

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago