add v2 services

This commit is contained in:
Alex Holliday committed 2025-09-23 15:22:08 -07:00
1 parent 35a712eafb
commit 68f4adfbfe
24 files changed
+3132

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import jwt from "jsonwebtoken";
import { AuthResult } from "../service/v2/business/AuthService.js";
const encode = (data: AuthResult): string => {
const secret = process.env.JWT_SECRET;
if (!secret) {
throw new Error("JWT_SECRET is not defined");
}
const token = jwt.sign(data, secret, { expiresIn: "99d" });
return token;
};
const decode = (token: string): AuthResult => {
const secret = process.env.JWT_SECRET;
if (!secret) {
throw new Error("JWT_SECRET is not defined");
}
const decoded = jwt.verify(token, secret) as AuthResult;
return decoded;
};
export { encode, decode };