Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ladjs/koa-better-flash
Flash message middleware for Koa and Passport
https://github.com/ladjs/koa-better-flash
cookie cookies flash info koa messages messaging node passport queue redis sessions
Last synced: 3 months ago
JSON representation
Flash message middleware for Koa and Passport
- Host: GitHub
- URL: https://github.com/ladjs/koa-better-flash
- Owner: ladjs
- License: mit
- Created: 2017-09-04T21:11:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-20T17:39:11.000Z (almost 5 years ago)
- Last Synced: 2024-10-11T17:44:05.361Z (4 months ago)
- Topics: cookie, cookies, flash, info, koa, messages, messaging, node, passport, queue, redis, sessions
- Language: JavaScript
- Homepage:
- Size: 64.5 KB
- Stars: 9
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# koa-better-flash
[![build status](https://semaphoreci.com/api/v1/niftylettuce/koa-better-flash/branches/master/shields_badge.svg)](https://semaphoreci.com/niftylettuce/koa-better-flash)
[![code coverage](https://img.shields.io/codecov/c/github/niftylettuce/koa-better-flash.svg)](https://codecov.io/gh/niftylettuce/koa-better-flash)
[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://github.com/lassjs/lass)
[![license](https://img.shields.io/github/license/niftylettuce/koa-better-flash.svg)](<>)> Flash message middleware for Koa and Passport
## Table of Contents
* [Install](#install)
* [Usage](#usage)
* [Contributors](#contributors)
* [License](#license)## Install
[npm][]:
```sh
npm install koa-better-flash
```[yarn][]:
```sh
yarn add koa-better-flash
```## Usage
```js
const Koa = require('koa');
const Router = require('koa-router');
const session = require('koa-generic-session');
const flash = require('koa-better-flash');const app = new Koa();
const router = new Router();router.post('/', (ctx, next) => {
// you can also pass an array of messages:
// ctx.flash('info', [ 'hi', 'hello', 'good morning' ]);
ctx.flash('info', 'hello world');
ctx.status = 200;
});router.get('/', ctx => {
// to get all messages by type simply call `ctx.flash()`
ctx.body = ctx.flash('info');
// outputs: [ 'hello world ']
});app.keys = [ 'keys' ];
app.use(session());
app.use(flash());
app.use(router.routes());
app.listen();
```## Contributors
| Name | Website |
| -------------- | -------------------------- |
| **Nick Baugh** | |## License
[MIT](LICENSE) © [Nick Baugh](http://niftylettuce.com/)
##
[npm]: https://www.npmjs.com/
[yarn]: https://yarnpkg.com/