MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / sessionFileContent

Function sessionFileContent

src/auth/authFiles/session.server.ts:3–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { getConfig } from "../../config";
2
3export const sessionFileContent = () => {
4 const runtimeDependency = getConfig().get<string>("runtimeDependency") || "@remix-run/node";
5 return [
6 `import { createCookieSessionStorage } from "${runtimeDependency}";`,
7 "",
8 "// export the whole sessionStorage object",
9 "export const sessionStorage = createCookieSessionStorage({",
10 " cookie: {",
11 ' name: "_session", // use any name you want here',
12 ' sameSite: "lax", // this helps with CSRF',
13 ' path: "/", // remember to add this so the cookie will work in all routes',
14 " httpOnly: true, // for security reasons, make this cookie http only",
15 " secrets: [process.env.SESSION_SECRET], // replace this with an actual secret",
16 ' secure: process.env.NODE_ENV === "production", // enable this in prod only',
17 " },",
18 "});",
19 "",
20 "// you can also export the methods individually for your own usage",
21 "export const { getSession, commitSession, destroySession } = sessionStorage;",
22 ].join("\n");
23};

Callers 1

generateAuthFunction · 0.90

Calls 1

getConfigFunction · 0.90

Tested by

no test coverage detected