hapi — Quick Access to Logged In User in Route Handlers

Frameworks hide technical complexity and provide a stable basis for reusable components. Additionally to the general usage of frameworks, you’re constantly looking for ways to improve your daily development flow. You’re most likely using the same pattern throughout your code.

Especially for web apps built with hapi, you may access request.auth.credentials within most of your request handlers. Mostly via a temporary variable like const user = request.auth.credentials..

What if you could access the requesting user data via request.user? That would remove some extra lines of code within multiple route handlers and still keep the code readability. Also, it’s a short statement and you can immediately recognize what user data is accessed.

hapi Series Overview

Continue reading

University Enrollment Required

Future Students benefit from value packed videos and tutorials.

Enroll to receive exclusive content or sign in if you’re already a Future Student.

Enroll me for $15/mo

Explore the Library

Find interesting tutorials and solutions for your problems.