expressjs / flash Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hello world,
I would like to request a feature: TypeScript support.
I am going to to try to pull together a pull request if I can.
Thanks!
Hi, I have a problem with flashes in twig. I want pop stack of flash and write messages to template. For pop stack i use shift() like written in doc. But it's not works. Twig not support while loop, only for with syntax for <i> in <source>
. Useless for pop flash stack.
{% for alert in flash.shift() %}
<div class="alert alert-{{alert.type}} alert-dismissible fade show general-alert" role="alert">
{{alert.message}}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{% endfor %}
How I solve this problem?
use while message = flash.shift() get value too cumbersome。
Some values are not my concern
I just want error_message value
Whether this can be req.flash('message') ?
I modified code
after flash('message') the 'message' be delete, no need to manually shift.
function push(type, msg) {
var res = this.res || this;
var locals = res.locals.flash;
if(!msg){
if(typeof type === 'string' && locals.length){
for(var i = 0, l = locals.length; i < l; i++){
if(locals[i]['type'] === type){
msg = locals[i]['message'];
locals.splice(i, 1);
return msg;
}
}
}
return;
}
msg = {
message: msg,
type: type
}
var messages = res.locals.flash
// do not allow duplicate flash messages
for (var i = 0; i < messages.length; i++) {
var message = messages[i]
if (msg.type === message.type && msg.message === message.message) return this
}
messages.push(msg)
return this
}
It doesn't say anywhere the difference between this flash version and the popular connect-flash:
https://github.com/jaredhanson/connect-flash
Hello,
I have this session
app.use(session({ secret: 'changeme' , cookie: { secure: false, maxAge: new Date(Date.now() + 3600000), } , resave:false, saveUninitialized:false, store: new SkinStore(db) }));
when using flash it will stuck on the session and not to be expired !
should I destory the flash session manually
By include app.use(flash())
, a cookie is set on client side even the middleware is not used to set any flash message. This will prevent caching efficiently.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.