server-connect.io
v1.0.1
Published
A middleware for managing flash messages in Express.js applications, providing a simple interface for setting and retrieving messages that persist across requests.
Downloads
4
Readme
Instalação
npm install server-connect.io
Demonstração
1- Create a new Express application and set up sessions:
const express = require('express');
const session = require('express-session');
const flash = require('server-connect.io');
const app = express();
app.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: true }));
app.use(flash());
app.use(flash.clearFlash());
app.get('/', (req, res) => {
req.flash('info', 'Welcome!');
res.send(req.flash('info'));
});
app.listen(3000, () => {
console.log('Server started on http://localhost:3000');
});
2- Using flash messages in routes:
app.get('/', (req, res) => {
req.flash('info', 'Welcome!');
res.send(req.flash('info'));
});
app.listen(3000, () => {
console.log('Server started on http://localhost:3000');
});
Setting a flash message
req.flash(type, msg);
npm install server-connect.io
Demonstração
1- Create a new Express application and set up sessions:
const express = require('express');
const session = require('express-session');
const flash = require('server-connect.io');
const app = express();
app.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: true }));
app.use(flash());
app.use(flash.clearFlash());
app.get('/', (req, res) => {
req.flash('info', 'Welcome!');
res.send(req.flash('info'));
});
app.listen(3000, () => {
console.log('Server started on http://localhost:3000');
});
2- Using flash messages in routes:
app.get('/', (req, res) => {
req.flash('info', 'Welcome!');
res.send(req.flash('info'));
});
app.listen(3000, () => {
console.log('Server started on http://localhost:3000');
});
Setting a flash message
req.flash(type, msg);