inertia-sails 0.3.2 → 0.3.3
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,17 @@
|
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
success: req.flash('success')
|
|
11
|
-
}
|
|
12
|
-
hook.share('flash', flash)
|
|
13
|
-
|
|
14
|
-
const validationErrors = resolveValidationErrors(req)
|
|
15
|
-
req.flash('errors', validationErrors)
|
|
16
|
-
|
|
17
|
-
hook.share('errors', req.flash('errors')[0] || {})
|
|
4
|
+
const flash = {
|
|
5
|
+
message: req.flash('message'),
|
|
6
|
+
error: req.flash('error'),
|
|
7
|
+
success: req.flash('success')
|
|
18
8
|
}
|
|
19
9
|
|
|
10
|
+
hook.share('flash', flash)
|
|
11
|
+
|
|
12
|
+
const validationErrors = resolveValidationErrors(req)
|
|
13
|
+
req.flash('errors', validationErrors)
|
|
14
|
+
hook.share('errors', req.flash('errors')[0] || {})
|
|
20
15
|
return next()
|
|
21
16
|
}
|
|
22
17
|
}
|