Skip to content

Instantly share code, notes, and snippets.

@antonkalik
Created March 9, 2024 23:31
Show Gist options
  • Save antonkalik/58c5a0e3d269ba02ffa409c507568d78 to your computer and use it in GitHub Desktop.
Save antonkalik/58c5a0e3d269ba02ffa409c507568d78 to your computer and use it in GitHub Desktop.
Token service with constructor
export class TokenService {
private jwt_secret: string;
constructor() {
if (!process.env.JWT_SECRET) {
throw new Error('JWT secret not found in environment variables!');
}
this.jwt_secret = process.env.JWT_SECRET;
}
public verify(token: string) {
// Implementation...
}
public sign(payload) {
// Implementation...
}
}
const tokenService = new TokenService();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment