Skip to content

Instantly share code, notes, and snippets.

@antonkalik
Created March 9, 2024 23:23
Show Gist options
  • Save antonkalik/910b45e4452b93a9728f8c2b1c15ac8a to your computer and use it in GitHub Desktop.
Save antonkalik/910b45e4452b93a9728f8c2b1c15ac8a to your computer and use it in GitHub Desktop.
Token Service Handler
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