Welcome Guest, Not a member yet? Register   Sign In
nodejs tips and tricks
#21

A week with hapijs (thoughts)

After spending a week with hapijs I just want to tell you my initial thoughts.

Firstly, this is difficult, you will be scratching your head most of the time. The syntax is confusing, something you can end with a semi colon sometimes you don't. This depends on the library you are using. Second, even with hapijs you need a lot of middleware. You need a plugin to serve files and images, there is no official server side session management, it is a repo created by someone. Yes it has client side cookie management but remember how happy we were when codeigniter finally added native PHP sessions to the framework!

Third, you'll have a lot of trouble following video tutorials most are written in earlier versions of hapi, so version 17 is completely different, the Joi, form validation for example, doesn't echo out the actual error messages, it just shows you a pass or fail message.

Connecting to a mysql database is easy enough if you use the mysql npm module, you can even use prepared statements and create a persistent connection. You can load other files on the fly and access their methods with.

https://www.sitepoint.com/understanding-...s-node-js/

For hashing passwords you have to use npm bcrypt, but on the mac that doesn't work so you have to use bcyrptjs, which is a subtlety that took ages to figure out.

Rendering views is fairly easy if you are using handlebars. To access POST data you need to call the data.payload method.

It becomes a bit tedious to start and stop the server to debug the program, so I recommend using node supervisor which allows you to change code without restarting the server.

https://github.com/petruisfan/node-supervisor

I did briefly take a look at full MVC frameworks like sails, but they are huge and confusing. Overall, it was a very frustrating experience. But I feel now I can create a simple framework that does most of the things codeigniter does albeit without it all being nicely wrapped within helpers functions etc.

I'm glad I did try this as it is always good to know as I think bigger companies will be looking for these skillsets, especially for multi-threading applications.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply


Messages In This Thread
nodejs tips and tricks - by ignitedcms - 09-10-2018, 12:42 PM
RE: nodejs tips and tricks - by ciadmin - 09-10-2018, 12:52 PM
RE: nodejs tips and tricks - by ignitedcms - 09-10-2018, 12:55 PM
RE: nodejs tips and tricks - by ciadmin - 09-10-2018, 01:03 PM
RE: nodejs tips and tricks - by ignitedcms - 09-10-2018, 01:05 PM
RE: nodejs tips and tricks - by ignitedcms - 09-10-2018, 01:13 PM
RE: nodejs tips and tricks - by donpwinston - 09-10-2018, 05:42 PM
RE: nodejs tips and tricks - by ignitedcms - 09-10-2018, 10:39 PM
RE: nodejs tips and tricks - by skunkbad - 09-12-2018, 01:08 AM
RE: nodejs tips and tricks - by ignitedcms - 09-12-2018, 03:04 AM
RE: nodejs tips and tricks - by skunkbad - 09-12-2018, 07:54 AM
RE: nodejs tips and tricks - by ignitedcms - 09-12-2018, 10:40 AM
RE: nodejs tips and tricks - by ignitedcms - 09-12-2018, 10:45 AM
RE: nodejs tips and tricks - by ignitedcms - 09-17-2018, 02:20 PM
RE: nodejs tips and tricks - by skunkbad - 09-17-2018, 03:44 PM
RE: nodejs tips and tricks - by ignitedcms - 09-17-2018, 08:52 PM
RE: nodejs tips and tricks - by ignitedcms - 09-18-2018, 06:38 AM
RE: nodejs tips and tricks - by ignitedcms - 09-18-2018, 11:42 AM
RE: nodejs tips and tricks - by skunkbad - 09-18-2018, 02:05 PM
RE: nodejs tips and tricks - by ignitedcms - 09-18-2018, 10:14 PM
RE: nodejs tips and tricks - by ignitedcms - 09-19-2018, 11:55 AM
RE: nodejs tips and tricks - by ignitedcms - 09-20-2018, 03:48 AM
RE: nodejs tips and tricks - by ignitedcms - 09-20-2018, 09:25 AM
RE: nodejs tips and tricks - by skunkbad - 09-20-2018, 10:26 AM
RE: nodejs tips and tricks - by ignitedcms - 09-20-2018, 11:07 AM
RE: nodejs tips and tricks - by ignitedcms - 09-20-2018, 11:45 AM
RE: nodejs tips and tricks - by ignitedcms - 09-21-2018, 09:21 AM
RE: nodejs tips and tricks - by ignitedcms - 09-21-2018, 03:55 PM
RE: nodejs tips and tricks - by ignitedcms - 09-21-2018, 06:37 PM
RE: nodejs tips and tricks - by skunkbad - 09-21-2018, 11:07 PM
RE: nodejs tips and tricks - by ignitedcms - 09-21-2018, 11:31 PM
RE: nodejs tips and tricks - by skunkbad - 09-22-2018, 07:00 AM
RE: nodejs tips and tricks - by ignitedcms - 09-23-2018, 10:17 AM
RE: nodejs tips and tricks - by ignitedcms - 09-24-2018, 10:44 AM
RE: nodejs tips and tricks - by ignitedcms - 09-25-2018, 05:09 AM
RE: nodejs tips and tricks - by ignitedcms - 09-25-2018, 05:18 AM
RE: nodejs tips and tricks - by ignitedcms - 09-25-2018, 12:38 PM
RE: nodejs tips and tricks - by ignitedcms - 09-26-2018, 11:58 AM
RE: nodejs tips and tricks - by dave friend - 09-27-2018, 07:37 AM
RE: nodejs tips and tricks - by ignitedcms - 09-27-2018, 09:16 AM
RE: nodejs tips and tricks - by ignitedcms - 09-28-2018, 10:09 AM
RE: nodejs tips and tricks - by ignitedcms - 09-28-2018, 11:48 PM
RE: nodejs tips and tricks - by ignitedcms - 09-30-2018, 08:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB