Skip to content

Instantly share code, notes, and snippets.

@DimosthenisK
DimosthenisK / self.decorator.ts
Created December 17, 2019 10:14
NestJS Guard + Decorator that allows user access limit to his own resources
import { SetMetadata } from '@nestjs/common';
export interface SelfDecoratorParams {
userIDParam: string;
allowAdmins?: boolean;
}
export const Self = (params: SelfDecoratorParams | string) =>
SetMetadata(
'selfParams',
@DimosthenisK
DimosthenisK / axiosRetry.js
Last active October 25, 2019 11:56
Axios Request Retry function - ES7 implementation of axios request retry
/**
Asynchronous Recursive Request retry with Axios
Author: Dimosthenis Kalaitzis <dimostheniskalaitzis@gmail.com>
Requires Axios
Throws error after failing all available attempts
@param requestParams AxiosRequestOptions
@param attempts number
*/
async sendRequest(requestParams, attempts = 0) {