Skip to content

Instantly share code, notes, and snippets.

View EndyKaufman's full-sized avatar
👷‍♂️
working...

IL'shat Khamitov EndyKaufman

👷‍♂️
working...
View GitHub Profile
@EndyKaufman
EndyKaufman / SlackConfig.ts
Last active December 8, 2021 10:17
SlackModuleDI
export const SLACK_CONFIG = 'SLACK_CONFIG';
export interface SlackConfig {
serviceName: string;
enable?: boolean;
domain: string;
tag: string;
channel: string;
accessToken: string;
}
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
@EndyKaufman
EndyKaufman / CoreLogger.ts
Last active November 3, 2021 15:02
CoreLogger.ts
import { ConsoleLogger } from '@nestjs/common';
export class CoreLogger extends ConsoleLogger {
public static excludeContexts: string[] = [];
public static addExcludeContexts(excludeContext: string) {
CoreLogger.excludeContexts.push(excludeContext);
}
/**
* Write a 'log' level log.
*/
@EndyKaufman
EndyKaufman / CoreClassSerializerInterceptor.ts
Last active January 22, 2024 20:47
CoreClassSerializerInterceptor.ts
import { CallHandler, ClassSerializerInterceptor, ExecutionContext, Injectable, Logger, Module, PlainLiteralObject, SetMetadata, Type } from '@nestjs/common';
import { APP_INTERCEPTOR, Reflector } from '@nestjs/core';
import { ClassTransformOptions, plainToClass } from 'class-transformer';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
export const GQL_RETURN_TYPE = 'GQL_RETURN_TYPE';
export const GqlReturn = (type: Type<any>) => SetMetadata('GQL_RETURN_TYPE', type);
@EndyKaufman
EndyKaufman / CustomInjectorModule.ts
Last active June 16, 2024 12:25
CustomInjectorModule for NestJS
import { Module } from '@nestjs/common';
import { CustomInjectorService } from './CustomInjectorService';
@Module({
providers: [CustomInjectorService],
exports: [CustomInjectorService],
})
export class CustomInjectorModule {}
@EndyKaufman
EndyKaufman / callback-to-observable.ts
Created November 25, 2019 20:27
callback-to-observable.ts
import { Inject, Injectable } from '@nestjs/common';
import { from, Observable } from 'rxjs';
/**
* Костыль который превращает функции сервиса с калбак аргументом в обзервабл,
* для поддержки типизации в тестах
*
* @param service сервис созданный через загрузку прото файла (GRPC.loadPackageDefinition)
*/
// tslint:disable-next-line: typedef
@EndyKaufman
EndyKaufman / access.guard.ts
Created August 28, 2019 07:43
access.guard.ts
import { ExecutionContext, Injectable, Logger } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { AuthGuard } from '@nestjs/passport';
import { User } from '../entities/user.entity';
import { GqlExecutionContext } from '@nestjs/graphql';
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context.host';
@Injectable()
export class AccessGuard extends AuthGuard('jwt') {
constructor(private readonly reflector: Reflector) {
@EndyKaufman
EndyKaufman / rucken-todo-ionic.json
Created April 8, 2019 06:17
rucken-todo-ionic.json
{
"/api/(.*)": "https://core-nestjs.rucken.io/api/"
}