New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

koa-flash-message

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-flash-message

Flash Messages Middleware For Koa

latest
Source
npmnpm
Version
0.1.6
Version published
Maintainers
1
Created
Source

koa-flash-message

Build Status codecov

Flash messages middleware for koa v2 application.

Installation

$ npm install koa-flash-message

koa-flash-message middleware depends on koa-generic-session. You must add koa-generic-session as a middleware prior to adding koa-flash-message

Example

import Koa from 'koa';
import session from 'koa-generic-session';
import koaRedis from 'koa-redis';
import flashMessage from 'koa-flash-message';

const redisStore = koaRedis({
  url: config.redisUrl
});

const app = new Koa();

app.keys = [config.secretKeyBase];
app.use(convert(session({
  store: redisStore,
  prefix: '__sess:',
  key: '__sid'
})));

app.use(flashMessage);

add message to flash messages

ctx.flashMessage.warning = 'Log Out Successfully!';

read all flash messages

ctx.state.flashMessage.messages
// or ctx.flashMessage.messages

read warning message

ctx.state.flashMessage.warning
// or ctx.flashMessage.warning

Full Example Code

Author

  • Embbnux Ji

License

MIT

Keywords

flash-message

FAQs

Package last updated on 11 Feb 2017

Did you know?

Socket

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