1.1.0 • Published 1 year ago

nestjs-graphcdn v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Description

This's a module for Nest to handle the purge api from GraphCDN.

Installation

$ npm i --save nestjs-graphcdn

Quick Start

Using purge Interceptor

app.resolver.ts

  @Mutation()
  @UseInterceptors(new GraphCDNPurgeInterceptor({
        serviceName: "<service-name>",
        purgeToken: "<token>",
  }))
  async upvotePost(@Args('postId') postId: number) {
    ...
  }

Global

If you want to set up interceptor as global, you have to follow Nest instructions here. Something like this.

app.module.ts

import { APP_INTERCEPTOR } from "@nestjs/core";
import { GraphCDNPurgeInterceptor } from "nestjs-graphcdn";

@Module({
  providers: [
    {
      provide: APP_INTERCEPTOR,
      useValue: new GraphCDNPurgeInterceptor({
        serviceName: "<service-name>",
        purgeToken: "<token>",
      }),
    },
  ],
})
export class ApplicationModule {}

Use purge query decorator

To purge some queries you can now use the GraphCDNPurgeQuery decorator.

app.resolver.ts

import { GraphCDNPurgeQuery } from "nestjs-graphcdn"

@Mutation()
@GraphCDNPurgeQuery(["<query-name>"])
async upvotePost(@Args('postId') postId: number) {
  ...
}

Use purge type decorator

To purge some type you can now use the GraphCDNPurgeType decorator.

app.resolver.ts

import { GraphCDNPurgeType } from "nestjs-graphcdn"

@Mutation()
@GraphCDNPurgeType("<type-name>", "<type-id-reference>")
async upvotePost(@Args('postId') postId: number) {
  ...
}
1.1.0

1 year ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago