nestjs-scanloader
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Nest Logo

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.

Readme

Keywords

Package Sidebar

Install

npm i nestjs-scanloader

Weekly Downloads

3

Version

2.0.3

License

MIT

Unpacked Size

23.6 kB

Total Files

21

Last publish

Collaborators

  • reiva