Gathering detailed insights and metrics for @mgcrea/fastify-session-prisma-store
Gathering detailed insights and metrics for @mgcrea/fastify-session-prisma-store
Gathering detailed insights and metrics for @mgcrea/fastify-session-prisma-store
Gathering detailed insights and metrics for @mgcrea/fastify-session-prisma-store
npm install @mgcrea/fastify-session-prisma-store
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (93.46%)
JavaScript (6.54%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
4 Stars
30 Commits
2 Watchers
2 Branches
1 Contributors
Updated on Jul 03, 2025
Latest Version
1.3.1
Package Id
@mgcrea/fastify-session-prisma-store@1.3.1
Unpacked Size
26.26 kB
Size
5.64 kB
File Count
9
NPM Version
10.9.2
Node Version
22.14.0
Published on
Jul 03, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Prisma session store for fastify.
1npm install fastify-cookie @mgcrea/fastify-session @mgcrea/fastify-session-prisma-store 2# or 3pnpm add fastify-cookie @mgcrea/fastify-session @mgcrea/fastify-session-prisma-store
Add the following table definition to your schema.prisma
:
1model Session { 2 id BigInt @id @default(autoincrement()) @db.BigInt 3 sid String @unique 4 5 data Json 6 7 expiresAt DateTime 8 createdAt DateTime @default(now()) 9 updatedAt DateTime @updatedAt 10 11 @@map("sessions") 12}
1import createFastify, { FastifyInstance, FastifyServerOptions } from "fastify"; 2import fastifyCookie from "fastify-cookie"; 3import PrismaStore from "@mgcrea/fastify-session-prisma-store"; 4import fastifySession from "@mgcrea/fastify-session"; 5import { prisma } from "./config/prisma"; 6 7const SESSION_TTL = 864e3; // 1 day in seconds 8 9export const buildFastify = (options?: FastifyServerOptions): FastifyInstance => { 10 const fastify = createFastify(options); 11 12 fastify.register(fastifyCookie); 13 fastify.register(fastifySession, { 14 store: new PrismaStore({ prisma }), 15 secret: "a secret with minimum length of 32 characters", 16 cookie: { maxAge: SESSION_TTL }, 17 }); 18 19 return fastify; 20};
You can use the DEBUG
environment variable to toggle the debug output for this package:
1DEBUG=fastify-session-prisma-store npm start
1The MIT License 2 3Copyright (c) 2023 Olivier Louvignes <olivier@mgcrea.io> 4 5Permission is hereby granted, free of charge, to any person obtaining a copy 6of this software and associated documentation files (the "Software"), to deal 7in the Software without restriction, including without limitation the rights 8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9copies of the Software, and to permit persons to whom the Software is 10furnished to do so, subject to the following conditions: 11 12The above copyright notice and this permission notice shall be included in 13all copies or substantial portions of the Software. 14 15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21THE SOFTWARE.
No vulnerabilities found.
No security vulnerabilities found.