nestjs-stellate
v1.1.1
Published
Stellate.co Module for Nest Framework
Downloads
728
Readme
Description
This's a module for Nest to handle the purge api from Stellate.
Installation
$ npm i --save nestjs-stellate
Quick Start
Using purge Interceptor
app.resolver.ts
@Mutation()
@UseInterceptors(new StellatePurgeInterceptor({
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 { StellatePurgeInterceptor } from "nestjs-stellate";
@Module({
providers: [
{
provide: APP_INTERCEPTOR,
useValue: new StellatePurgeInterceptor({
serviceName: "<service-name>",
purgeToken: "<token>",
}),
},
],
})
export class ApplicationModule {}
Use purge query decorator
To purge some queries you can now use the StellatePurgeQuery
decorator.
app.resolver.ts
import { StellatePurgeQuery } from "nestjs-stellate"
@Mutation()
@StellatePurgeQuery(["<query-name>"])
async upvotePost(@Args('postId') postId: number) {
...
}
Use purge type decorator
To purge some type you can now use the StellatePurgeType
decorator.
app.resolver.ts
import { StellatePurgeType } from "nestjs-stellate"
@Mutation()
@StellatePurgeType("<type-name>", "<type-id-reference>")
async upvotePost(@Args('postId') postId: number) {
...
}