feat: initial boilerplate
This commit is contained in:
25
api/libraries/auth/config.ts
Normal file
25
api/libraries/auth/config.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import type { SerializeOptions } from "cookie";
|
||||
|
||||
import { getEnvironmentVariable, toBoolean } from "~libraries/config/mod.ts";
|
||||
|
||||
export const config = {
|
||||
privateKey: getEnvironmentVariable(
|
||||
"AUTH_PRIVATE_KEY",
|
||||
await readFile(resolve(import.meta.dirname!, ".keys", "private"), "utf-8"),
|
||||
),
|
||||
publicKey: getEnvironmentVariable(
|
||||
"AUTH_PUBLIC_KEY",
|
||||
await readFile(resolve(import.meta.dirname!, ".keys", "public"), "utf-8"),
|
||||
),
|
||||
cookie: (maxAge: number) =>
|
||||
({
|
||||
httpOnly: true,
|
||||
secure: getEnvironmentVariable("AUTH_COOKIE_SECURE", toBoolean, "false"), // Set to true for HTTPS in production
|
||||
maxAge,
|
||||
path: "/",
|
||||
sameSite: "strict",
|
||||
}) satisfies SerializeOptions,
|
||||
};
|
||||
Reference in New Issue
Block a user