Middleware Explained

  Рет қаралды 2,939

Syntax

3 ай бұрын

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 KZfaq.
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: www.youtube.com/@randyrektor
Syntax: syntaxfm
www.syntax.fm
Brought to you by Sentry.io
#webdevelopment #webdeveloper #javascript

Пікірлер: 21
@prashlovessamosa
@prashlovessamosa 3 ай бұрын
Please never stop making awesome videos. It's super refreshing to hear both of you.
@syntaxfm
@syntaxfm 3 ай бұрын
🫡
@L.A.Frazier
@L.A.Frazier 3 ай бұрын
WES BOS. THE MOISTMAKER.
@2breezy866
@2breezy866 3 ай бұрын
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.
@erikslorenz
@erikslorenz 3 ай бұрын
I think middleware in general is one of the coolest things in web dev
@buddy.abc123
@buddy.abc123 3 ай бұрын
In next.js you can split your middleware into file/ function that export function that take NextMiddleware and return NextMiddleware
@rrd_webmania
@rrd_webmania 3 ай бұрын
Nuxt middleware are really flexible both server and client side
@alexdeathway
@alexdeathway 3 ай бұрын
More videos discussing concept like this.
@WesBos
@WesBos 3 ай бұрын
coming up! LMK if you have any requests!
@alexdeathway
@alexdeathway 3 ай бұрын
@@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.
@SheeceGardazi
@SheeceGardazi 3 ай бұрын
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 kzfaq.info/get/bejne/i8iYm62Iu5nGnX0.html Protect SvelteKit Routes with Hooks kzfaq.info/get/bejne/gZeErMRn1Ny6f30.html
@syntaxfm
@syntaxfm 3 ай бұрын
We said put it in middleware (hooks.sever.ts)
@Kawiatube
@Kawiatube 3 ай бұрын
I do all three; hooks(populate user), layout(make sure, for layouts that require user), load function(to shut typescript up)
@SheeceGardazi
@SheeceGardazi 3 ай бұрын
@@Kawiatube The Problem with Using Layouts for Auth kzfaq.info/get/bejne/i8iYm62Iu5nGnX0.html
@SheeceGardazi
@SheeceGardazi 3 ай бұрын
@@Kawiatube The Problem with Using Layouts for Auth kzfaq.info/get/bejne/i8iYm62Iu5nGnX0.html
@SheeceGardazi
@SheeceGardazi 3 ай бұрын
@@Kawiatube i dont know why i cant share video from hunterbyte ... search for The Problem with Using Layouts for Auth
@intensedev
@intensedev 3 ай бұрын
Initialize a database connection in a middleware is definitely not a good idea, that would really increase the time between each fetch-request cycle
@syntaxfm
@syntaxfm 3 ай бұрын
In a server less context, where else would you initialize the connection, given that there is no long running process?
@AkinBelieve
@AkinBelieve 3 ай бұрын
On the topic of moist-makers. I hear Americans don't put butter in their sandwiches... that's wild.
@syntaxfm
@syntaxfm 3 ай бұрын
We don’t. 🇺🇸
@kelsey_roy
@kelsey_roy 3 ай бұрын
Middleware = interceptor