inertia-sails 0.1.8 → 0.1.9
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.
- package/package.json +2 -2
- package/private/inertia-middleware.js +22 -20
- package/inertia-sails-0.1.7.tgz +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inertia-sails",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "The Sails adapter for Inertia.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"sails": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/sailscastshq/boring-stack.git",
|
|
17
|
-
"directory": "
|
|
17
|
+
"directory": "inertia-sails"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"sails": ">=1",
|
|
@@ -11,27 +11,29 @@ const getPartialData = require('./get-partial-data')
|
|
|
11
11
|
const resolveValidationErrors = require('./resolve-validation-errors')
|
|
12
12
|
function inertia(sails, { hook, sharedProps, sharedViewData, rootView }) {
|
|
13
13
|
return function inertiaMiddleware(req, res, next) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
if (isInertiaRequest(req)) {
|
|
15
|
+
/**
|
|
16
|
+
* Flash messages stored in the session.
|
|
17
|
+
* @typedef {Object} FlashMessages
|
|
18
|
+
* @property {Array} message - Flash message(s).
|
|
19
|
+
* @property {Array} error - Error message(s).
|
|
20
|
+
* @property {Array} success - Success message(s).
|
|
21
|
+
*/
|
|
22
|
+
const flash = {
|
|
23
|
+
message: req.flash('message'),
|
|
24
|
+
error: req.flash('error'),
|
|
25
|
+
success: req.flash('success')
|
|
26
|
+
}
|
|
27
|
+
hook.share('flash', flash) // Share the flash object as props
|
|
28
|
+
/**
|
|
29
|
+
* Validation errors stored in the session, resolved and formatted for Inertia.js.
|
|
30
|
+
* @type {Object}
|
|
31
|
+
*/
|
|
32
|
+
const validationErrors = resolveValidationErrors(req)
|
|
33
|
+
req.flash('errors', validationErrors) // Flash the validation error so we can share it later
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
hook.share('errors', req.flash('errors')[0] || {}) // Share validation errors as props
|
|
36
|
+
}
|
|
35
37
|
|
|
36
38
|
hook.render = function (component, props = {}, viewData = {}) {
|
|
37
39
|
const allProps = {
|
package/inertia-sails-0.1.7.tgz
DELETED
|
Binary file
|