{"id":17692907,"url":"https://github.com/mgcrea/fastify-session-prisma-store","last_synced_at":"2025-05-13T02:47:30.450Z","repository":{"id":66212525,"uuid":"460812308","full_name":"mgcrea/fastify-session-prisma-store","owner":"mgcrea","description":"Prisma store for fastify-session","archived":false,"fork":false,"pushed_at":"2024-03-07T15:17:19.000Z","size":470,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-04T07:02:21.789Z","etag":null,"topics":["auth","fastify","postgresql","prisma","session"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mgcrea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-18T10:43:09.000Z","updated_at":"2023-03-10T09:55:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"a4a55984-6e84-424e-b7db-f2915b4aefbd","html_url":"https://github.com/mgcrea/fastify-session-prisma-store","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"5654dc396193a48ca6af4150f20a3c88b52cdbc6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgcrea%2Ffastify-session-prisma-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgcrea%2Ffastify-session-prisma-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgcrea%2Ffastify-session-prisma-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgcrea%2Ffastify-session-prisma-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgcrea","download_url":"https://codeload.github.com/mgcrea/fastify-session-prisma-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253862734,"owners_count":21975583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth","fastify","postgresql","prisma","session"],"created_at":"2024-10-24T13:07:32.240Z","updated_at":"2025-05-13T02:47:30.427Z","avatar_url":"https://github.com/mgcrea.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastifySession PrismaStore\n\n\u003c!-- markdownlint-disable MD033 --\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@mgcrea/fastify-session-prisma-store\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/@mgcrea/fastify-session-prisma-store.svg?style=for-the-badge\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@mgcrea/fastify-session-prisma-store\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/@mgcrea/fastify-session-prisma-store.svg?style=for-the-badge\" alt=\"npm total downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@mgcrea/fastify-session-prisma-store\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/@mgcrea/fastify-session-prisma-store.svg?style=for-the-badge\" alt=\"npm monthly downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@mgcrea/fastify-session-prisma-store\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/l/@mgcrea/fastify-session-prisma-store.svg?style=for-the-badge\" alt=\"npm license\" /\u003e\n  \u003c/a\u003e\n  \u003cbr /\u003e\n  \u003ca href=\"https://github.com/mgcrea/fastify-session-prisma-store/actions/workflows/main.yml\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/mgcrea/fastify-session-prisma-store/main.yml?style=for-the-badge\u0026branch=master\" alt=\"build status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://depfu.com/github/mgcrea/fastify-session-prisma-store\"\u003e\n    \u003cimg src=\"https://img.shields.io/depfu/dependencies/github/mgcrea/fastify-session-prisma-store?style=for-the-badge\" alt=\"dependencies status\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c!-- markdownlint-enable MD037 --\u003e\n\n## Features\n\n[Prisma](https://prisma.io) session store for [fastify](https://github.com/fastify/fastify).\n\n- Requires [@mgcrea/fastify-session](https://github.com/mgcrea/fastify-session) to handle sessions.\n- Written in [TypeScript](https://www.typescriptlang.org/) for static type checking with exported types along the library.\n- Built by [tsup](https://tsup.egoist.dev) to provide both CommonJS and ESM packages.\n\n## Install\n\n```bash\nnpm install fastify-cookie @mgcrea/fastify-session @mgcrea/fastify-session-prisma-store\n# or\npnpm add fastify-cookie @mgcrea/fastify-session @mgcrea/fastify-session-prisma-store\n```\n\n## Quickstart\n\nAdd the following table definition to your `schema.prisma`:\n\n```prisma\nmodel Session {\n  id        BigInt   @id @default(autoincrement()) @db.BigInt\n  sid       String   @unique\n  expires   DateTime\n  data      Json\n  createdAt DateTime @default(now())\n  updatedAt DateTime @updatedAt\n  @@map(\"sessions\")\n}\n```\n\n```ts\nimport createFastify, { FastifyInstance, FastifyServerOptions } from \"fastify\";\nimport fastifyCookie from \"fastify-cookie\";\nimport PrismaStore from \"@mgcrea/fastify-session-prisma-store\";\nimport fastifySession from \"@mgcrea/fastify-session\";\nimport { prisma } from \"./config/prisma\";\n\nconst SESSION_TTL = 864e3; // 1 day in seconds\n\nexport const buildFastify = (options?: FastifyServerOptions): FastifyInstance =\u003e {\n  const fastify = createFastify(options);\n\n  fastify.register(fastifyCookie);\n  fastify.register(fastifySession, {\n    store: new PrismaStore({ prisma }),\n    secret: \"a secret with minimum length of 32 characters\",\n    cookie: { maxAge: SESSION_TTL },\n  });\n\n  return fastify;\n};\n```\n\n## Debug\n\nYou can use the `DEBUG` environment variable to toggle the [debug](https://github.com/debug-js/debug) output for this package:\n\n```sh\nDEBUG=fastify-session-prisma-store npm start\n```\n\n## Authors\n\n- [Olivier Louvignes](https://github.com/mgcrea) \u003c\u003colivier@mgcrea.io\u003e\u003e\n\n## License\n\n```txt\nThe MIT License\n\nCopyright (c) 2023 Olivier Louvignes \u003colivier@mgcrea.io\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgcrea%2Ffastify-session-prisma-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgcrea%2Ffastify-session-prisma-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgcrea%2Ffastify-session-prisma-store/lists"}