Novice Prime Minister

    @intelrug/nestjs-bunnycdn
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.1 • Public • Published

    @intelrug/nestjs-bunnycdn

    Integrates BunnyCDN with Nest

    NPM Version Package License NPM Downloads

    Install

    $ yarn add @intelrug/nestjs-bunnycdn

    Usage

    BunnyCDNModule.forRoot(options, connection?)

    import { Module } from '@nestjs/common';
    import { BunnyCDNModule } from '@intelrug/nestjs-bunnycdn';
    import { AppController } from './app.controller';
    
    @Module({
      imports: [
        BunnyCDNModule.forRoot({
          apiAccessKey: 'your-key',
          storageZones: [{
            name: 'your-storage-zone-name',
            accessKey: 'your-storage-zone-access-key'
          }],
        }),
      ],
      controllers: [AppController],
    })
    export class AppModule {}

    BunnyCDNModule.forRootAsync(options, connection?)

    import { Module } from '@nestjs/common';
    import { BunnyCDNModule } from '@intelrug/nestjs-bunnycdn';
    import { AppController } from './app.controller';
    
    @Module({
      imports: [
        BunnyCDNModule.forRootAsync({
          useFactory: () => ({
            apiAccessKey: 'your-key',
            storageZones: [{
              name: 'your-storage-zone-name',
              accessKey: 'your-storage-zone-access-key'
            }],
          }),
        }),
      ],
      controllers: [AppController],
    })
    export class AppModule {}

    InjectBunnyCDN(connection?)

    import { Controller, Get, } from '@nestjs/common';
    import { InjectBunnyCDN } from '@intelrug/nestjs-bunnycdn';
    import { BunnyCDN, PullZone } from '@intelrug/bunnycdn';
    
    @Controller()
    export class AppController {
      constructor(
        @InjectBunnyCDN() private readonly bunny: BunnyCDN,
      ) {}
    
      @Get()
      async getHello(): Promise<PullZone[]> {
        try {
          await this.bunny.pullZone.create({
            Name: 'my-pull-zone',
            OriginUrl: 'http://my-site.com',
            Type: 0
          });
          return this.bunny.pullZone.get();
        } catch (e) {
          console.log(e);
        }
      }
    }

    Install

    npm i @intelrug/nestjs-bunnycdn

    DownloadsWeekly Downloads

    4

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    22.9 kB

    Total Files

    24

    Last publish

    Collaborators

    • intelrug