Gathering detailed insights and metrics for @fastify/flash
Gathering detailed insights and metrics for @fastify/flash
Gathering detailed insights and metrics for @fastify/flash
Gathering detailed insights and metrics for @fastify/flash
npm install @fastify/flash
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
29 Stars
167 Commits
14 Forks
17 Watching
3 Branches
27 Contributors
Updated on 25 Nov 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-28.6%
1,993
Compared to previous day
Last week
-11.3%
13,772
Compared to previous week
Last month
10.5%
67,797
Compared to previous month
Last year
9.2%
703,131
Compared to previous year
1
The flash is a special area of the session used for storing messages. Messages are written to the flash and cleared after being displayed to the user. The flash is typically used in combination with redirects, ensuring that the message is available to the next page that is to be rendered.
This plugin is inspired by connect-flash.
npm i @fastify/flash
Flash messages are stored in the session. First, we need to register the session plugin: @fastify/secure-session.
1const fastify = require('fastify')() 2const fastifySession = require('@fastify/secure-session') 3const fastifyFlash = require('@fastify/flash') 4 5fastify.register(fastifySession, { 6 // adapt this to point to the directory where secret-key is located 7 key: fs.readFileSync(path.join(__dirname, 'secret-key')), 8 cookie: { 9 // options from setCookie, see https://github.com/fastify/fastify-cookie 10 } 11}) 12fastify.register(fastifyFlash) 13 14fastify.get('/test', (req, reply) => { 15 req.flash('warning', ['username required', 'password required']) 16 17 const warning = reply.flash('warning') 18 reply.send({ warning }) // {"warning":["username required","password required"]} 19})
@fastify/secure-session
can be replaced by any session plugin as long as it:
Signature
1req.flash(type: string, ...message: string[] | [string[]]): number
It can be called in three different ways:
req.flash('info', 'Welcome back')
req.flash('warning', ['username required', 'password required'])
req.flash('info', 'Hello %s', 'Jared') // will use util.format to format the string
req.flash
returns the number of messages store with provided type.
signature
1reply.flash(type?: string): { [k: string]: undefined | string[] } | string[]
It can be called in two different ways:
reply.flash() // returns all messages as object { [k: string]: undefined | string[] }
reply.flash('info') // returns array of messages that are stored with provided type
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
13 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 9
Details
Reason
Found 9/21 approved changesets -- score normalized to 4
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More