Socket
Socket
Sign inDemoInstall

one-flash

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    one-flash

A flash implementation for Express that goes away after the first navigation.


Version published
Weekly downloads
7
increased by600%
Maintainers
1
Install size
19.9 kB
Created
Weekly downloads
 

Readme

Source

one-flash

NPM version Dependency Status Downloads

A flash implementation for Express that goes away after the first navigation.

Usage

npm install one-flash --save

Backend

add it as middleware AFTER session() in your app.js

app.use(session());
app.use(require('one-flash'));

In routes (or any handler)

router.get('/flash', function(req, res) {
    req.oneFlash('warning', 'hello redirect');
    res.redirect('/');
});

router.get('/flashrender', function(req, res) {
    req.oneFlash('hello render');
    res.render('index', {
        title: 'Index - TEST'
    });
});

Frontend

(Nunjucks + bootstrap.js 3.x)

  {% for message in flash %}
  <div class="alert alert-{{ message.type if message.type else "info" }} alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    {{ message.message }}
  </div>
  {% endfor %}

API

oneFlash adds a property to locals called "flash", its value is an array of "flash" objects.

res.locals.flash = [
  {
    type: 'info',
    message: 'hello flash',
  }
];

Tests

None yet. You should know in less than 60 seconds if its working or not. Just output the value of flash in your view.

Keywords

FAQs

Last updated on 11 Feb 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc