Fix JS middlewares ⚒️

This commit is contained in:
Julien Nahum 2023-01-27 18:55:02 +01:00
parent 2b02667f34
commit 2536368e77
4 changed files with 78 additions and 12 deletions

View File

@ -48,6 +48,7 @@
"barryvdh/laravel-ide-helper": "^2.12", "barryvdh/laravel-ide-helper": "^2.12",
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^1.9.1",
"laravel/dusk": "^6.8", "laravel/dusk": "^6.8",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.2", "mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^6.1", "nunomaduro/collision": "^6.1",
"pestphp/pest": "^1.15", "pestphp/pest": "^1.15",

64
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "f7f1a45b1eda3403d140b878030defd7", "content-hash": "2e93597a584b3252f740cd2bd6e0a0da",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
@ -11462,6 +11462,66 @@
}, },
"time": "2022-09-29T09:37:07+00:00" "time": "2022-09-29T09:37:07+00:00"
}, },
{
"name": "laravel/sail",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/sail.git",
"reference": "a64f78a4ab86c04a4c5de39bea20a8d36ad48a22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/sail/zipball/a64f78a4ab86c04a4c5de39bea20a8d36ad48a22",
"reference": "a64f78a4ab86c04a4c5de39bea20a8d36ad48a22",
"shasum": ""
},
"require": {
"illuminate/console": "^8.0|^9.0|^10.0",
"illuminate/contracts": "^8.0|^9.0|^10.0",
"illuminate/support": "^8.0|^9.0|^10.0",
"php": "^7.3|^8.0"
},
"bin": [
"bin/sail"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
},
"laravel": {
"providers": [
"Laravel\\Sail\\SailServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Sail\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Docker files for running a basic Laravel application.",
"keywords": [
"docker",
"laravel"
],
"support": {
"issues": "https://github.com/laravel/sail/issues",
"source": "https://github.com/laravel/sail"
},
"time": "2023-01-11T14:35:04+00:00"
},
{ {
"name": "mockery/mockery", "name": "mockery/mockery",
"version": "1.5.1", "version": "1.5.1",
@ -14746,5 +14806,5 @@
"ext-pcntl": "8.0", "ext-pcntl": "8.0",
"ext-posix": "8.0" "ext-posix": "8.0"
}, },
"plugin-api-version": "2.1.0" "plugin-api-version": "2.3.0"
} }

View File

@ -25,7 +25,6 @@
<server name="APP_ENV" value="testing"/> <server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/> <server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/> <server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="pgsql"/>
<server name="DB_FOREIGN_KEYS" value="(false)"/> <server name="DB_FOREIGN_KEYS" value="(false)"/>
<server name="MAIL_MAILER" value="log"/> <server name="MAIL_MAILER" value="log"/>
<server name="MAIL_FROM_ADDRESS" value="notifications@notionforms.io"/> <server name="MAIL_FROM_ADDRESS" value="notifications@notionforms.io"/>

View File

@ -90,8 +90,6 @@ async function beforeEach (to, from, next) {
router.app.setLayout(components[0].layout) router.app.setLayout(components[0].layout)
} else if (components[0].default && components[0].default.layout) { } else if (components[0].default && components[0].default.layout) {
router.app.setLayout(components[0].default.layout) router.app.setLayout(components[0].default.layout)
} else {
router.app.setLayout('')
} }
} }
@ -133,7 +131,10 @@ function callMiddleware (middleware, to, from, next) {
return next(...args) return next(...args)
} }
const { middleware, params } = parseMiddleware(stack.pop()) const {
middleware,
params
} = parseMiddleware(stack.pop())
if (typeof middleware === 'function') { if (typeof middleware === 'function') {
middleware(to, from, _next, params) middleware(to, from, _next, params)
@ -183,7 +184,6 @@ function getMiddleware (components) {
const middleware = [...globalMiddleware] const middleware = [...globalMiddleware]
components.forEach(component => { components.forEach(component => {
let compMiddleware let compMiddleware
if (component.middleware) { if (component.middleware) {
compMiddleware = component.middleware compMiddleware = component.middleware
@ -191,10 +191,12 @@ function getMiddleware (components) {
compMiddleware = component.default.middleware compMiddleware = component.default.middleware
} }
if (Array.isArray(compMiddleware)) { if (compMiddleware) {
middleware.push(...compMiddleware) if (Array.isArray(compMiddleware)) {
} else { middleware.push(...compMiddleware)
middleware.push(compMiddleware) } else {
middleware.push(compMiddleware)
}
} }
}) })
@ -237,7 +239,11 @@ function scrollBehavior (to, from, savedPosition) {
* @param {Object} requireContext * @param {Object} requireContext
* @return {Object} * @return {Object}
*/ */
function resolveMiddleware(requireContext) { /**
* @param {Object} requireContext
* @return {Object}
*/
function resolveMiddleware (requireContext) {
const middlewares = {} const middlewares = {}
Object.keys(requireContext) Object.keys(requireContext)
.map(file => .map(file =>