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
57.4
Supply Chain
97.3
Quality
77.2
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
3,623
Last Day
24
Last Week
60
Last Month
148
Last Year
1,951
4 Stars
27 Commits
2 Watching
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.3.0
Package Id
@mgcrea/fastify-session-prisma-store@1.3.0
Unpacked Size
25.74 kB
Size
5.46 kB
File Count
9
NPM Version
10.2.4
Node Version
20.11.1
Publised On
07 Mar 2024
Cumulative downloads
Total Downloads
Last day
500%
24
Compared to previous day
Last week
87.5%
60
Compared to previous week
Last month
20.3%
148
Compared to previous month
Last year
81.5%
1,951
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 expires DateTime 5 data Json 6 createdAt DateTime @default(now()) 7 updatedAt DateTime @updatedAt 8 @@map("sessions") 9}
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.