npm install nestjs-file-system
*** Pre-release, in development ***
I'm coding this library for my needs, but I'm open to feature submissions
NestJs-File-System is build using the NestJs Dynamic modules and Factory providers approach, to configure it import the NfsModule
module and the forRootFtpAsync
service.
For example, your AppModule
should look like this :
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config'
import { NfsModule } from 'nestjs-file-system';
@Module({
imports: [
ConfigModule,
NfsModule.forRootFtpAsync(),
],
providers: [],
controllers: [],
})
export class AppModule {}
Then just inject the service just like any local service
For Example:
import { Injectable, ServiceUnavailableException, Logger } from '@nestjs/common';
import { NfsModule } from 'nestjs-file-system';
@Injectable()
export class AppService {
private logger = new Logger('AppService', { timestamp: true });
constructor(private readonly _nfsService: NfsModule){}
public listFile(path: string): Dirent[] {
try {
return this._nfsService.listFile(path)
} catch (e) {
this.logger.error(JSON.stringify(e));
throw new ServiceUnavailableException(e);
}
}
}
Licensed under the MIT License - see the LICENSE file for details.