Package Exports
- kisapmata
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (kisapmata) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
kisapmata
"o kay bilis naman maglaho"
Install
Choose 1 of 3 options:
Install from NPM:
npm install kisapmataInstall latest from GitHub:
npm install github:kosinix/kisapmataTied to a specific version/release from GitHub:
npm install github:kosinix/kisapmata#1.1.0Quickstart
Include it:
const flash = require('kisapmata');In Express:
Note: This assumes that you have registered the express-session middleware
const session = require('express-session');
router.use(session());In routes:
router.post('/edit-profile', async (req, res, next) => {
try {
flash.set(req, 'success', 'Changes saved.') // Create flash message. Pass Express's req variable. Assign to key "success". Message is "Changes saved."
res.redirect('/edit-profile')
} catch (err) {
next(err);
}
});
router.get('/edit-profile', async (req, res, next) => {
try {
let okMessage = flash.get(req, 'success') // Get message with key 'success'
res.render('edit-profile.html', {
okMessage: okMessage
}) // Pass flash message to template
} catch (err) {
next(err);
}
});Advanced Usage
Its meant to be used with express sessions so the default path is 'session.flash.${id}'.
Change the path to something and use it outside express apps:
flash.set(myCustomVariable, 'success', 'Changes saved.', 'path.custom.${id}') // Here ${id} becomes 'success'
let x = flash.get(myCustomVariable, 'success', 'path.custom.${id}') // Make sure the path matches the one used in flash.set