Categories hapi

16 posts

Auto Added by WPeMatico

hapi โ€” Test Route Handlers by Injecting Requests

One of the reasons weโ€™re passionate about hapi is its easiness of testing. The framework has a built-in server.inject method that simulates an incoming HTTP request. A server.inject call wonโ€™t create a socket connection. Youโ€™re not relying to the network stack to run tests in your app. That means, testing […]

hapi โ€” Run Tests with Assertions using Code

Testing your hapi applications might require expected values and responses that match a set of data. The code library from hapiโ€™s ecosystem is an assertions library based on chai. Code exposes an expressive and readable language-style interface. Youโ€™ll get a grasp on features and the usage in the upcoming sections. […]

๐ŸŒŸ learn hapi โ€” Generate a Username in Mongoose Middleware

You added a profile editing screen in the previous tutorial. This profile editing view lets users update their personal username and homepage. Up to this point, each user has a blank profile after signing up. Following this tutorial, youโ€™ll generate a username based on the userโ€™s email address when saving […]

๐ŸŒŸ learn hapi โ€” Add CSRF Protection on Forms and API Endpoints

During the last weeks, you made tremendous progress on โ€œlearn hapiโ€ and your Futureflix app grows in functionality. Up to this point, you rely on hapiโ€™s built-in security mechanisms. We didnโ€™t care about adding custom protection yet (which is totally fine). That changes now and itโ€™s what youโ€™ll tackle in […]