re-order alot, move to bun redis, generalized
All checks were successful
Code quality checks / biome (push) Successful in 8s
All checks were successful
Code quality checks / biome (push) Successful in 8s
This commit is contained in:
parent
a646607597
commit
8a9499be85
51 changed files with 559 additions and 916 deletions
27
config/jwt.ts
Normal file
27
config/jwt.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
const allowedAlgorithms = [
|
||||
"HS256",
|
||||
"RS256",
|
||||
"HS384",
|
||||
"HS512",
|
||||
"RS384",
|
||||
"RS512",
|
||||
] as const;
|
||||
|
||||
type AllowedAlgorithm = (typeof allowedAlgorithms)[number];
|
||||
|
||||
function getAlgorithm(envVar: string | undefined): AllowedAlgorithm {
|
||||
if (allowedAlgorithms.includes(envVar as AllowedAlgorithm)) {
|
||||
return envVar as AllowedAlgorithm;
|
||||
}
|
||||
return "HS256";
|
||||
}
|
||||
|
||||
export const jwt: {
|
||||
secret: string;
|
||||
expiration: string;
|
||||
algorithm: AllowedAlgorithm;
|
||||
} = {
|
||||
secret: process.env.JWT_SECRET || "",
|
||||
expiration: process.env.JWT_EXPIRATION || "1h",
|
||||
algorithm: getAlgorithm(process.env.JWT_ALGORITHM),
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue