inertia-sails 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,23 @@
1
- const isInertiaRequest = require('../helpers/is-inertia-request')
2
-
3
1
  const resolveValidationErrors = require('../helpers/resolve-validation-errors')
4
2
  function inertia(hook) {
5
3
  return function inertiaMiddleware(req, res, next) {
6
- if (isInertiaRequest(req)) {
7
- const flash = {
8
- message: req.flash('message'),
9
- error: req.flash('error'),
10
- success: req.flash('success')
11
- }
12
- hook.share('flash', flash)
13
-
14
- const validationErrors = resolveValidationErrors(req)
15
- req.flash('errors', validationErrors)
4
+ // Skip Inertia middleware for WebSocket requests
5
+ // WebSocket requests don't have req.flash() and don't need Inertia rendering
6
+ if (req.isSocket) {
7
+ return next()
8
+ }
16
9
 
17
- hook.share('errors', req.flash('errors')[0] || {})
10
+ const flash = {
11
+ message: req.flash('message'),
12
+ error: req.flash('error'),
13
+ success: req.flash('success')
18
14
  }
19
15
 
16
+ hook.share('flash', flash)
17
+
18
+ const validationErrors = resolveValidationErrors(req)
19
+ req.flash('errors', validationErrors)
20
+ hook.share('errors', req.flash('errors')[0] || {})
20
21
  return next()
21
22
  }
22
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inertia-sails",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "The Sails adapter for Inertia.",
5
5
  "main": "index.js",
6
6
  "sails": {