Это видео недоступно.
Сожалеем об этом.
Middleware Explained
HTML-код
- Опубликовано: 15 авг 2024
- Join Wes and Scott for a hasty episode of Syntax as they unpack the power of middleware for developers, covering caching, authentication, A/B testing, error handling, and user redirection in a quick, punchy rundown to supercharge your backend skills!
Show Notes
00:00 Welcome to Syntax!
00:41 Syntax on RUclips.
01:28 What is middleware?
05:04 Some real-world examples of middleware.
05:10 Authentication.
07:44 Redirecting users to a specific instance.
08:28 Logging + statistics.
09:41 Debugging.
10:00 Timers.
10:46 A/B testing.
11:59 Error handling + logging.
12:23 Caching.
13:02 Multi-tenant applications.
15:08 Where does it run?
18:07 What are the limitations?
21:52 Next.js middleware is one file only.
23:35 Sveltekit solution.
24:31 Connect style.
25:28 One last thing, NPM Installing.
All links available at syntax.fm/747
------------------------------------------------------------------------------
Hit us up on Socials!
Scott: / stolinski
Wes: / wesbos
Randy: / @randyrektor
Syntax: / syntaxfm
www.syntax.fm
Brought to you by Sentry.io
#webdevelopment #webdeveloper #javascript
Please never stop making awesome videos.
It's super refreshing to hear both of you.
🫡
WES BOS. THE MOISTMAKER.
I think middleware in general is one of the coolest things in web dev
You can actually write middleware outside of the middleware.ts file in Next.js. It’s not as pretty as connect-style middleware, but it is possible. In app router, you simple create a higher-order function that either returns a response or calls the route handler, which is passed in as a parameter.
Nuxt middleware are really flexible both server and client side
In next.js you can split your middleware into file/ function that export function that take NextMiddleware and return NextMiddleware
No, no, no authentication in layout while using sveltekit ... It becomes stale upon navigation. Use individual page load functions to check authentication.
The Problem with Using Layouts for Auth ruclips.net/video/UbhhJWV3bmI/видео.html
Protect SvelteKit Routes with Hooks ruclips.net/video/K1Tya6ovVOI/видео.html
We said put it in middleware (hooks.sever.ts)
I do all three; hooks(populate user), layout(make sure, for layouts that require user), load function(to shut typescript up)
@@Kawiatube The Problem with Using Layouts for Auth ruclips.net/video/UbhhJWV3bmI/видео.html
@@Kawiatube The Problem with Using Layouts for Auth ruclips.net/video/UbhhJWV3bmI/видео.html
@@Kawiatube i dont know why i cant share video from hunterbyte ... search for The Problem with Using Layouts for Auth
More videos discussing concept like this.
coming up! LMK if you have any requests!
@@WesBos Nothing in particular, just the way you explained the concept and dropped some examples of implementation was quite intriguing, so a topic related to backend would be more than welcome also subscribed you.
On the topic of moist-makers. I hear Americans don't put butter in their sandwiches... that's wild.
We don’t. 🇺🇸
Initialize a database connection in a middleware is definitely not a good idea, that would really increase the time between each fetch-request cycle
In a server less context, where else would you initialize the connection, given that there is no long running process?
Middleware = interceptor