This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magic = { | |
res_jbody_to_env: [ | |
{ | |
access: ['data', 'access_token'] | |
}, | |
], | |
req_jbody_to_env: [ | |
{ | |
email: ["email"], | |
name: ["name"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function computeArrOfKeys< | |
T extends object, | |
R extends readonly (keyof T)[], | |
A extends readonly string[]>( | |
obj: Required<Record<keyof Required<T>, null>>, | |
rm: R, ...add: A) { | |
const origin = new Set(Object.keys(obj)); | |
add.forEach((a) => origin.add(a)); | |
rm.forEach((r) => origin.delete(r as string)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { EventPattern } from '@nestjs/microservices'; | |
export function EventPatternByMethodName() { | |
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { | |
EventPattern(propertyKey)(target, propertyKey, descriptor); | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type ValueByKeyType<T extends Record<string, any>, S extends keyof T> = T[S]; | |
/** | |
* Example of usage | |
**/ | |
import { ClientProxy } from '@nestjs/microservices'; | |
export type OverrideMicroClient<T extends Record<string, anny>> = Omit<ClientProxy, 'send' | 'emit'> & { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Prettify<T> = { | |
[K in keyof T]: T[K]; | |
} & {}; | |
export type Prefixed<T, P extends string> = { | |
[K in keyof T as K extends string ? `${P}${K}` : never]: T[K]; | |
}; | |
export type OmitStrict<T extends Record<string, any>, K extends keyof T> = Omit< | |
T, |