# nestjs-scanloader

> nestjs scan & autoload providers and controllers

Latest version **2.0.3** (published 2021-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install nestjs-scanloader
pnpm add nestjs-scanloader
yarn add nestjs-scanloader
bun add nestjs-scanloader
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2021-10-06 |
| First published | 2021-03-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 23 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Reiva |
| Maintainers | reiva |
| Keywords | nestjs, scan, loader |

## Links

- npm: https://www.npmjs.com/package/nestjs-scanloader
- Repository: https://github.com/SirReiva/nestjs-scanloader
- Homepage: https://github.com/SirReiva/nestjs-scanloader#readme
- Issues: https://github.com/SirReiva/nestjs-scanloader/issues
- npm.io page: https://npm.io/package/nestjs-scanloader

## Dependencies (3)

- [rxjs](https://npm.io/package/rxjs.md) ^7.3.1
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.7
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) ^8.0.10

## Recent versions

- 2.0.3 (latest) — 2021-10-06
- 2.0.2 — 2021-09-15
- 2.0.1 — 2021-09-15
- 2.0.0 — 2021-09-14
- 1.0.7 — 2021-07-09
- 1.0.6 — 2021-03-08
- 1.0.5 — 2021-03-07
- 1.0.2 — 2021-03-07
- 1.0.1 — 2021-03-05
- 1.0.0 — 2021-03-05

## README

<p align="center">
  <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>

## Description

[Nest](https://github.com/nestjs/nest) module for autoload providers and controllers.

## Installation

```bash
$ npm install nestjs-scanloader
```

## Example

```TS
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

```TS
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

```TS
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](https://www.npmjs.com/package/fast-glob) expressions for match controllers.
-   providersPaths: list of [FastGlob](https://www.npmjs.com/package/fast-glob) expressions for match providers.
-   imports: list of dependecies modules for autolad provides and controllers.
-   ignores: list of [FastGlob](https://www.npmjs.com/package/fast-glob) expressions for ignore during scan.
-   export: if autoload providers need to be exported.

## Module decorator options

Extends default metadata for Module Nest decorator

```TS
export interface IScanOptions {
    basePath: string;
    controllersPaths?: string[];
    providersPaths?: string[];
    ignores?: string[];
}
```

-   basePath: url root for controllersPaths and providersPaths.
-   controllersPaths: list of [FastGlob](https://www.npmjs.com/package/fast-glob) expressions for match controllers.
-   providersPaths: list of [FastGlob](https://www.npmjs.com/package/fast-glob) expressions for match providers.
-   ignores: list of [FastGlob](https://www.npmjs.com/package/fast-glob) expressions for ignore during scan.

## License

Nest is [MIT licensed](LICENSE).

---
_Source: https://npm.io/package/nestjs-scanloader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
