Fix build checks
This commit is contained in:
1 parent
72bcc0d020
commit
cdb83bb47d
2 files changed
-37
No files matched your search
@@ -1,15 +0,0 @@
|
||||
class ApiError extends Error {
|
||||
public status: number;
|
||||
|
||||
constructor(message: string, status: number = 500) {
|
||||
super(message);
|
||||
this.status = status;
|
||||
this.name = this.constructor.name;
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ApiError;
|
||||
@@ -1,22 +0,0 @@
|
||||
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 };
|
||||
Reference in new issue
Block a user