🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@platohq/nestjs-imagekit

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@platohq/nestjs-imagekit

The NestJS module based on the official Imagekit package

0.0.3
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
3
Weekly downloads
 
Created
Source

@platohq/nestjs-imagekit

The NestJS module based on the official Imagekit package

How to install

npm install @platohq/nestjs-imagekit

or

yarn add @platohq/nestjs-imagekit

How to use

Register the module

import { ImagekitModule } from '@platohq/nestjs-imagekit';

@Module({
  imports: [
    ImagekitModule.register({
      privateKey: 'YOUR_PRIVATE_KEY',
      publicKey: 'YOUR_PUBLIC_KEY',
      urlEndpoint: 'YOUR_URL_ENDPOINT',
    }),
  ],
})
export class AppModule {}

Inject the service

import { ImagekitService } from '@platohq/nestjs-imagekit';

@Injectable()
export class AppService {
  constructor(private readonly imagekitService: ImagekitService) {}

  track() {
    this.imagekitService.track('MY_EVENT');
  }
}

Async options

Quite often you might want to asynchronously pass your module options instead of passing them beforehand. In such case, use registerAsync() method, that provides a couple of various ways to deal with async data.

Use factory

ImagekitModule.registerAsync({
  useFactory: () => ({
    privateKey: 'YOUR_PRIVATE_KEY',
    publicKey: 'YOUR_PUBLIC_KEY',
    urlEndpoint: 'YOUR_URL_ENDPOINT',
  }),
});

Use class

ImagekitModule.registerAsync({
  useClass: ImagekitConfigService,
});

Above construction will instantiate ImagekitConfigService inside ImagekitModule and will leverage it to create options object.

class ImagekitConfigService implements ImagekitOptionsFactory {
  createImagekitOptions(): ImagekitModuleOptions {
    return {
      privateKey: 'YOUR_PRIVATE_KEY',
      publicKey: 'YOUR_PUBLIC_KEY',
      urlEndpoint: 'YOUR_URL_ENDPOINT',
    };
  }
}

Use existing

ImagekitModule.registerAsync({
  imports: [ConfigModule],
  useExisting: ConfigService,
}),

FAQs

Package last updated on 17 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts