()
| 1 | import { getConfig } from "../../config"; |
| 2 | |
| 3 | export 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 | }; |
no test coverage detected