@dxdeveloperexperience/hygie
Version:
Hygie is an easy-to-use Open-Source REST API allowing you to interact with GIT events. This NestJS API expose a set of customizable rules to automate your project's life cycle.
28 lines (24 loc) • 731 B
text/typescript
import {
Injectable,
NestInterceptor,
ExecutionContext,
CallHandler,
} from '@nestjs/common';
import { Observable, of } from 'rxjs';
import { Webhook } from '../webhook/webhook';
import { GitEventEnum } from '../webhook/utils.enum';
()
export class EnvVarInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
const request = context.switchToHttp().getRequest();
const incomingWebhook: Webhook = request.body;
if (
incomingWebhook.gitEvent === GitEventEnum.Push &&
incomingWebhook.getBranchName() === incomingWebhook.getDefaultBranchName()
) {
return next.handle();
} else {
return of([]);
}
}
}