{"_id":"@codecorn/connect-flash-new","_rev":"4-4c32f00e47cb3d453b0e408ac1e5c8ef","name":"@codecorn/connect-flash-new","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@codecorn/connect-flash-new","version":"1.0.0","keywords":["express","connect","flash","messages","middleware","typescript"],"author":{"name":"Federico Girolami","email":"f.girolami@codecorn.it"},"license":"MIT","_id":"@codecorn/connect-flash-new@1.0.0","maintainers":[{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"}],"homepage":"https://github.com/fgirolami29/connect-flash-new#readme","bugs":{"url":"https://github.com/fgirolami29/connect-flash-new/issues"},"dist":{"shasum":"4fd03e07a6dc7370a6858232f0317d48c7465041","tarball":"https://registry.npmjs.org/@codecorn/connect-flash-new/-/connect-flash-new-1.0.0.tgz","fileCount":8,"integrity":"sha512-MABj2f2wfMncq4Dj0wLpgtRwMb+sNgHJysw1+mIG/21qKg5PY1FqRFcXLRBJuLYbIARxaVRzaRjZJCchNXhMLQ==","signatures":[{"sig":"MEQCIB9fJ6QPmTNmt1C18mgKsEwe6YBOp4uLBXzVvWX4ApyoAiAM3UHs2O352qzdspOIy0yg6nNLeqMnd2/lefnBsX3PFw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8666},"main":"lib/index.js","type":"commonjs","types":"types/connect-flash.d.ts","gitHead":"770359e24421039936e4d22b0cff58f4c8d342ee","scripts":{"lint":"eslint .","test":"jest"},"_npmUser":{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"},"repository":{"url":"git+https://github.com/fgirolami29/connect-flash-new.git","type":"git"},"_npmVersion":"11.5.1","description":"Modern, type-safe Express flash middleware maintained by CodeCorn.","directories":{"lib":"lib","test":"test"},"_nodeVersion":"22.17.1","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.0.0","express":"^4.18.0","supertest":"^6.3.0","express-session":"^1.17.3"},"_npmOperationalInternal":{"tmp":"tmp/connect-flash-new_1.0.0_1754142906496_0.007640066181961558","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@codecorn/connect-flash-new","version":"1.0.2","keywords":["express","connect","flash","messages","middleware","typescript"],"author":{"name":"Federico Girolami","email":"f.girolami@codecorn.it"},"license":"MIT","_id":"@codecorn/connect-flash-new@1.0.2","maintainers":[{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"}],"homepage":"https://github.com/fgirolami29/connect-flash-new#readme","bugs":{"url":"https://github.com/fgirolami29/connect-flash-new/issues"},"dist":{"shasum":"c49cbbd44474325a6131a139d7efec1a88fa5bc7","tarball":"https://registry.npmjs.org/@codecorn/connect-flash-new/-/connect-flash-new-1.0.2.tgz","fileCount":8,"integrity":"sha512-0eb8ZrxcaBGcWpkIUJQy6QcHlT1C2eAtWxxfgASiOyfQJ45KdVwJq4CPZ5lSM5O5NMJU/EFnZ6mIGvhMOT8jUQ==","signatures":[{"sig":"MEUCIQCH09uEknZSq1w6L6yHRW6iz3AArk0/awtsRqv/P96DQQIgDqyw6bbMm1XlGiHdMbjlT+5wVBZ+j94GU+gEg0eGyk4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8733},"main":"lib/index.js","type":"commonjs","types":"types/connect-flash.d.ts","gitHead":"92ceb823550979aa570fe7efc0bd28cb7bf43099","scripts":{"lint":"eslint .","test":"jest"},"_npmUser":{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"},"repository":{"url":"git+https://github.com/fgirolami29/connect-flash-new.git","type":"git"},"_npmVersion":"11.5.1","description":"Modern, type-safe Express flash middleware maintained by CodeCorn.","directories":{"lib":"lib","test":"test"},"_nodeVersion":"22.17.1","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.0.0","express":"^4.18.0","supertest":"^6.3.0","express-session":"^1.17.3"},"_npmOperationalInternal":{"tmp":"tmp/connect-flash-new_1.0.2_1754144785455_0.8020050934887357","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@codecorn/connect-flash-new","version":"1.0.3","keywords":["express","connect","flash","messages","middleware","typescript"],"author":{"name":"Federico Girolami","email":"f.girolami@codecorn.it"},"license":"MIT","_id":"@codecorn/connect-flash-new@1.0.3","maintainers":[{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"}],"homepage":"https://github.com/fgirolami29/connect-flash-new#readme","bugs":{"url":"https://github.com/fgirolami29/connect-flash-new/issues"},"dist":{"shasum":"30506c2bedaed6841b8e1874cea4e9cd58a1fabf","tarball":"https://registry.npmjs.org/@codecorn/connect-flash-new/-/connect-flash-new-1.0.3.tgz","fileCount":8,"integrity":"sha512-qfCCNJpacWkvxdAgVDWDZXopvNyxBnKDHOtFMFadkMtx7lwq1POGBEJrTy3h+S7/93hmItymfIPCM9P/XcyuDQ==","signatures":[{"sig":"MEQCIENaMgHS9wfOaCCb9ybjvuLjw834I8UrUHo5LxcAEx3xAiAES/u8m8rCZVviME9O5zVYrsyA5YAZvSsFhjcX3RlS/Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8733},"main":"lib/index.js","type":"commonjs","types":"types/connect-flash.d.ts","gitHead":"5d7d3fbc1fb8ce54b14655fe44d12287042f17b8","scripts":{"lint":"eslint .","test":"jest"},"_npmUser":{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"},"repository":{"url":"git+https://github.com/fgirolami29/connect-flash-new.git","type":"git"},"_npmVersion":"11.5.1","description":"Modern, type-safe Express flash middleware maintained by CodeCorn.","directories":{"lib":"lib","test":"test"},"_nodeVersion":"22.17.1","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.0.0","express":"^4.18.0","supertest":"^6.3.0","express-session":"^1.17.3"},"_npmOperationalInternal":{"tmp":"tmp/connect-flash-new_1.0.3_1754145140869_0.638729972248802","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@codecorn/connect-flash-new","version":"1.0.4","description":"Modern, type-safe Express flash middleware maintained by CodeCorn.","keywords":["express","connect","flash","messages","middleware","typescript"],"homepage":"https://github.com/fgirolami29/connect-flash-new#readme","bugs":{"url":"https://github.com/fgirolami29/connect-flash-new/issues"},"repository":{"type":"git","url":"git+https://github.com/fgirolami29/connect-flash-new.git"},"license":"MIT","author":{"name":"Federico Girolami","email":"f.girolami@codecorn.it"},"type":"commonjs","main":"lib/index.js","types":"types/connect-flash.d.ts","directories":{"lib":"lib","test":"test"},"scripts":{"test":"jest","lint":"eslint ."},"devDependencies":{"jest":"^29.0.0","supertest":"^6.3.0","express":"^4.18.0","express-session":"^1.17.3","cookie-parser":"^1.4.7"},"_id":"@codecorn/connect-flash-new@1.0.4","gitHead":"e801e1b0d92a7fec7c0f4b133fc249ce24d06cee","_nodeVersion":"22.17.1","_npmVersion":"11.5.1","dist":{"integrity":"sha512-ZcWytBi/kMv4GhKrVmVPEX/7WDM/FP5sXL4Zr58FnBspKkeXnIX+MzFaFwoV9D3MO+bmZI+z+YFfRK7IBHeh0A==","shasum":"653beaf0b3bc58cf7a4481c425514a45361d9cd6","tarball":"https://registry.npmjs.org/@codecorn/connect-flash-new/-/connect-flash-new-1.0.4.tgz","fileCount":12,"unpackedSize":12851,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFng7OA03+KhBTjfoeFLGA4djWVWgj1tzhjmnoH+jl14AiBIaXMJBsE7hf/kYwdENxr44aLV5PYgf0U+48Z69rSjJg=="}]},"_npmUser":{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"},"maintainers":[{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/connect-flash-new_1.0.4_1754148475620_0.14163991818982358"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-02T13:55:06.420Z","modified":"2025-08-02T15:27:56.035Z","1.0.0":"2025-08-02T13:55:06.674Z","1.0.2":"2025-08-02T14:26:25.656Z","1.0.3":"2025-08-02T14:32:21.060Z","1.0.4":"2025-08-02T15:27:55.820Z"},"bugs":{"url":"https://github.com/fgirolami29/connect-flash-new/issues"},"author":{"name":"Federico Girolami","email":"f.girolami@codecorn.it"},"license":"MIT","homepage":"https://github.com/fgirolami29/connect-flash-new#readme","keywords":["express","connect","flash","messages","middleware","typescript"],"repository":{"type":"git","url":"git+https://github.com/fgirolami29/connect-flash-new.git"},"description":"Modern, type-safe Express flash middleware maintained by CodeCorn.","maintainers":[{"name":"fgirolami29","email":"federicogirolami.fg@gmail.com"}],"readme":"# connect-flash-new\n\n<div style=\"display: flex;align-items: center\">\n<div style=\"width:60%\">\n\n> A modern, type-safe, and fully compatible flash messaging middleware for Express.\n> This project is a clean reimplementation of the original `connect-flash` — actively maintained by the community, for the community.\n\n</div>\n  <div style=\"width:40%\">\n    <p align=\"right\">\n      <a href=\"https://github.com/fgirolami29/connect-flash-new/stargazers\">\n        <img src=\"https://img.shields.io/github/stars/fgirolami29/connect-flash-new?style=social\" alt=\"Star on GitHub\">\n      </a>\n      <a href=\"https://www.npmjs.com/package/@codecorn/connect-flash-new\">\n        <img src=\"https://img.shields.io/npm/v/@codecorn/connect-flash-new\" alt=\"npm version\">\n      </a>\n      <a href=\"https://github.com/fgirolami29/connect-flash-new/issues\">\n        <img src=\"https://img.shields.io/github/issues/fgirolami29/connect-flash-new.svg\" alt=\"open issues\">\n      </a>\n      <a href=\"https://github.com/fgirolami29/connect-flash-new/actions\">\n        <img src=\"https://github.com/fgirolami29/connect-flash-new/actions/workflows/test.yml/badge.svg\" alt=\"CI Status\">\n      </a>\n      <a href=\"https://github.com/fgirolami29/connect-flash-new/graphs/contributors\">\n        <img src=\"https://img.shields.io/github/contributors/fgirolami29/connect-flash-new.svg\" alt=\"contributors\">\n      </a>\n    </p>\n  </div>\n</div>\n\n---\n\n## ✨ Features\n\n-   🔐 Safe flash message handling via session\n-   🧠 TypeScript-ready (`.d.ts` included)\n-   ♻️ Fully compatible with CommonJS (`require`) and ES Modules (`import`)\n-   🧪 Easy to test (with `supertest`)\n-   🔥 Drop-in replacement for deprecated `connect-flash`\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @codecorn/connect-flash-new\n```\n\n---\n\n## 🚀 Usage\n\n```js\n// ✅ ESM / TypeScript\nimport express from 'express';\nimport session from 'express-session';\nimport flash from '@codecorn/connect-flash-new';\n\n// ✅ CommonJS (require)\nconst express = require('express');\nconst session = require('express-session');\nconst flash = require('@codecorn/connect-flash-new');\n\nconst app = express();\n\napp.use(session({ secret: 'secret', resave: false, saveUninitialized: true }));\napp.use(flash());\n\napp.get('/', (req, res) => {\n    req.flash('info', 'Welcome back %s!', 'Federico');\n    res.send(req.flash('info'));\n});\n```\n\n---\n\n## 🧪 Testing with Supertest\n\n```js\n// ✅ ESM\nimport request from 'supertest';\nimport express from 'express';\nimport session from 'express-session';\nimport flash from '@codecorn/connect-flash-new';\n\n// ✅ CommonJS\nconst request = require('supertest');\nconst express = require('express');\nconst session = require('express-session');\nconst flash = require('@codecorn/connect-flash-new');\n\nconst app = express();\napp.use(session({ secret: 'test', resave: false, saveUninitialized: true }));\napp.use(flash());\n\napp.get('/test', (req, res) => {\n    req.flash('info', 'Test Message');\n    res.json({ messages: req.flash('info') });\n});\n\ntest('should return flash message', async () => {\n    const res = await request(app).get('/test');\n    expect(res.body.messages).toContain('Test Message');\n});\n```\n\n---\n\n## 🔐 Safe Init Helper (Optional)\n\nIf you want a one-liner to safely initialize both `cookie-parser` and `connect-flash-new`, you can use our helper:\n\n```js\nconst express = require('express');\nconst session = require('express-session');\nconst { safeFlashInit } = require('@codecorn/connect-flash-new/helpers');\n\nconst app = express();\napp.use(session({ secret: process.env.SESSION_SECRET, resave: false, saveUninitialized: true }));\n\nsafeFlashInit(app); // Will use process.env.SESSION_SECRET or throw a warning\n```\n\n---\n\n## 🧪 Experimental: `flashMessages` Middleware (Preview)\n\nIn alternativa al classico `flash()`, puoi usare `flashMessages` per accedere ai messaggi flash direttamente in `res.locals.sessionFlash`.\nQuesta funzionalità è **opt-in** e può essere abilitata nel tuo `.env` o in modo programmatico:\n\n```js\n// lib/flashMessages.js\nimport { flashMessages } from '@codecorn/connect-flash-new';\n\napp.use(flashMessages);\n```\n\n### 🔧 Attivazione condizionata via `.env`\n\nPuoi attivarlo dinamicamente leggendo da `.env`:\n\n```js\nif (process.env.ENABLE_FLASH_MESSAGES === 'true') {\n    app.use(flashMessages);\n}\n```\n\nQuesto middleware:\n\n-   🔄 Passa i messaggi da `req.session.flash` a `res.locals.sessionFlash`\n-   🧼 Svuota la sessione per evitare messaggi duplicati/zombie\n-   🛡️ Inizializza `req.session.flash` se mancante\n\n> ⚠️ In fase sperimentale — potrà evolvere con il feedback della community.\n\n---\n\n## 🙏 Credits\n\nOriginally inspired by [connect-flash](https://github.com/jaredhanson/connect-flash) by @jaredhanson.  \nThis project continues the spirit of the original package, updated for modern Node.js and TypeScript environments.\n\n---\n\n## 👤 Maintainer\n\n<div style=\"display: flex; justify-content: space-between; align-items: center;\"> \n  <div> \n    <p><strong>👨‍💻 Federico Girolami</strong></p> \n    <p><strong>Full Stack Developer</strong> | <strong>System Integrator</strong> | <strong>Digital Solution Architect</strong> 🚀</p> \n    <p>📫 <strong>Get in Touch</strong></p> \n    <p>🌐 <strong>Website</strong>: <a href=\"https://codecorn.it\">codecorn.it</a> *(Under Construction)*</p> \n    <p>📧 <strong>Email</strong>: <a href=\"mailto:f.girolami@codecorn.it\">f.girolami@codecorn.it</a></p> \n    <p>🐙 <strong>GitHub</strong>: <a href=\"https://github.com/fgirolami29\">github.com/fgirolami29</a></p> \n  </div> \n  <div style=\"text-align: center;\">\n    <a href=\"https://www.codecorn.it\"> \n      <img src=\"https://codecorn.it/wp-content/uploads/2025/05/CODECORN-trasp-qhite.png\" alt=\"Code Corn Logo\"  width=\"250px\" height=\"90px\" style=\"margin-top:30px;margin-bottom:20px;\"/>\n    </a> \n    <a href=\"https://github.com/fgirolami29\"> \n      <img src=\"https://avatars.githubusercontent.com/u/68548715?s=200&v=4\" alt=\"Federico Girolami Avatar\" style=\"border-radius: 50%; width: 125px; height: 125px;border: 5px solid gold\" /> \n    </a> \n  </div> \n</div>\n","readmeFilename":"README.md"}