test: add keys folder
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { JwtModuleAsyncOptions } from "@nestjs/jwt";
|
||||
|
||||
export function jwtConfig(): JwtModuleAsyncOptions {
|
||||
return {
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
secret: configService.getOrThrow<string>("JWT_SECRET_KEY"),
|
||||
}),
|
||||
useFactory: (configService: ConfigService) => {
|
||||
const privateKeyPath = join(process.cwd(), "keys", "private.pem");
|
||||
const publicKeyPath = join(process.cwd(), "keys", "public.pem");
|
||||
|
||||
return {
|
||||
privateKey: readFileSync(privateKeyPath, "utf8"),
|
||||
publicKey: readFileSync(publicKeyPath, "utf8"),
|
||||
signOptions: {
|
||||
algorithm: "RS256",
|
||||
issuer: configService.getOrThrow<string>("JWT_ISSUER"),
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user