Created
March 9, 2024 23:23
-
-
Save antonkalik/910b45e4452b93a9728f8c2b1c15ac8a to your computer and use it in GitHub Desktop.
Token Service Handler
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 tokenServiceHandler = { | |
get(target, propKey, receiver) { | |
const originalMethod = target[propKey]; | |
if (typeof originalMethod === 'function') { | |
return function(...args) { | |
if (!TokenService.jwt_secret) { | |
throw new Error('Secret not found in environment variables!'); | |
} | |
return originalMethod.apply(this, args); | |
}; | |
} | |
return originalMethod; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment