Simple http ipfs client. Part of Lido NestJS Modules.
yarn add @poolsea-nestjs/ipfs-http-client
This module depends on FetchModule
from @poolsea-nestjs/fetch
, so you need to provide it as a global module or import it into IpfsModule
.
// Import
import { Module } from '@nestjs/common';
import { IpfsModule } from '@poolsea-nestjs/offchain-key-storage-client';
import { FetchModule } from '@poolsea-nestjs/fetch';
import { MyService } from './my.service';
@Module({
imports: [
IpfsModule.forFeature({
imports: [FetchModule],
url: 'http://127.0.0.1:5001/api/v0',
username: 'username',
password: 'password',
}),
],
providers: [MyService],
exports: [MyService],
})
export class MyModule {}
// Provider usage
import { IpfsGeneralService } from '@poolsea-nestjs/offchain-key-storage-client';
export class MyService {
constructor(private ipfsService: IpfsGeneralService) {}
async myMethod() {
return await this.ipfsService.get(
'QmSJiSS956mnxk2UhWo5T7CqCebeDAS4BrnjuBM6VAeheT',
'http://127.0.0.1:5001/api/v0',
);
}
}
@Module({
imports: [
ConfigModule,
// FetchModule.forRoot(),
IpfsModule.forFeatureAsync({
imports: [CustomFetchModule],
async useFactory(config: ConfigService) {
return {
url: config.get('URL'),
username: config.get('USERNAME'),
password: config.get('PASSWORD'),
};
},
inject: [ConfigService],
}),
],
})
export class MyModule {}
import { Module } from '@nestjs/common';
import { IpfsModule } from '@poolsea-nestjs/offchain-key-storage-client';
import { FetchModule } from '@poolsea-nestjs/fetch';
@Module({
imports: [
IpfsModule.forRoot({
imports: [FetchModule],
url: 'http://127.0.0.1:5001/api/v0',
username: 'username',
password: 'password',
}),
// IpfsModule.forRootAsync({
// imports: [CustomFetchModule],
// async useFactory(config: ConfigService) {
// return {
// url: config.get('URL'),
// username: config.get('USERNAME'),
// password: config.get('PASSWORD'),
// };
// },
// inject: [ConfigService],
// }),
],
})
export class MyModule {}
Example of usage this library https://github.com/lidofinance/lido-offchain-key-lib-test.git