koa better flash
v0.0.4
มิดเดิลแวร์ข้อความแฟลชสำหรับ KOA และหนังสือเดินทาง
NPM:
npm install koa-better-flashเส้นด้าย:
yarn add koa-better-flash 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 ( ) ; | ชื่อ | เว็บไซต์ |
|---|---|
| Nick Baugh | http://niftylettuce.com/ |
mit © Nick Baugh