-
Notifications
You must be signed in to change notification settings - Fork 194
Potential [Assignment 5] Glue and HTML views #132
Comments
If we want to simplify the assignment, we could split it into two. |
I can see the follow up with glue but I don't think rendering views is. |
@AdriVanHoudt thanks for the input. End Goal: Is to build an application that has the following features:
In the end the application will have the following routes:
Validation versus rendering viewsIn order to begin writing code that validates submitted data, we need to create HTML pages that Why move hapi-auth-basic registration logicThere are several reasons to move the registration logic out of the private plugin.
loggingYes, we are going to add server logging eventually. Making use of a proper DB.Using a proper DB is super important. But, it should come after reaching the end goal described above. For now the plan is to use JSON objects as our data source. After we achieve our end goalIf we complete the above application, the hapijs community will have boilerplate code that many applications will be able to use regardless of the DB. We could then take that boilerplate code and start a new project like a todo application using MongoDB. It would feature user administration (CRUD) and todo list management. @AdriVanHoudt and community. Please share your thoughts :-) |
First of all, wow :D Last random thought, what if eventually this project will become the server that hosts the website that has the tutorial for this project? |
@zoe-1 Nice work, looks like a very good roadmap for a start! TLS, definitely must have. I like the idea of composing the app with glue, I'm currently using it on a project at work and I'm sold on configuration-centric apps anyway. And it has some small gotchas, so it would be nice to provide in this project an example of how to handle them. This way of bootstrapping an app may not be appreciated by everyone though. About the position of auth plugins registration, it's kind of a tricky subject as in real-world apps it would IMHO really depends on what kind of project you're working on and how your team is structured. Some things I'd add to the areas of study:
That's all that comes to my mind at the moment. |
Indeed there is no silver bullet but in our case I tend to lean towards keeping it in the plugin, for my daytime job I work alone on a server so in that case it doesn't really matter.
|
@AdriVanHoudt and @FennNaten Thank you for sharing your feedback! It feels like we are beginning to get a good sense of where our project needs to go. :-) In respect to building a tutorial website, I like the idea and hope we will do it. In respect to glue and the position of auth plugin(s) registration, there are two existing projects that provide example code of where to position the auth plugin(s) registration:
Both sites referenced above follow the style of registering and configuring authentication plugins outside of route handler plugins. And, this is style I recommend our project follow. In respect to the other areas of study you both wrote about, I think this discussion is important and this kind of feedback will shape the future of our project. From my perspective most everything you both mentioned would be useful to build. Thanks for sharing your thoughts. In respect integrating all those various topics you both metioned into one tutorial project, I am not quite sure what that would look like. If we accomplish our current goals and begin another phase of development I am sure we will have some good discussion about what to build next :-) |
Well those 2 projects need the auth in multiple plugins, so then it makes sense to take it out, in our case the auth is only needed in the routes of private. And yeah we need to come up with something that makes sense in the end and incorporates all the ideas ^^ |
@zoe-1 Good lack with taking that project forward, I'm here to help too. @AdriVanHoudt I also think that currently the About the next assignments, I would like to see After that we will have a good base to add cache and documentation, as @FennNaten mentioned. |
@idanwe Good thoughts above :-) Glad you want to help. In respect, to your thoughts about the private module and hapi-auth-basic. The main reason for moving it out of the private plugin into it's own auth file is because we are planning to build skeleton code for other developers to use. We expect them to want to build complex applications needing authentication strategies. So, it would make sense to design the auth registration code so others will not have to change too much when they start adding 5-10 plugins into their project. :-) My reasoning for using glue is it let's you easily add and manage plugins to your server. So, by using glue, we are designing with the expectation that future users (including us) will use this code to kickstart their hapi applications and want to add many plugins into the project. glue is a must for a hapijs project with many plugins (IMHO). If you are not using glue you will end up writing your own code to do what glue does. glue exists because the hapijs community developed a solution to a common issue all hapijs projects face (composing your server with all plugins and configurations in place). It is a good solution :-) Plus, I think it would be easier for people new to glue to add it to the project now before it gets complicated. |
@idanwe has a fair point, I have a server with 10 plugins atm (should be more but I didn't have a tutorial to learn from ;) ) and it's fine without glue. Glue would indeed work better for more complex configurations. And good point that db can also incorporate schema validation! @zoe-1 I do not agree with your 'main reason' of this project. My thought was that this was a way of learning Hapi. I see no reason to provide boilerplate code in a tutorial. Of course the tutorial will have code that can easily be 'copy & pasted' to use but that should not be the goal. The goal is to learn Hapi and all of it features and possibilities and in the process the 'student' (since we are a university now :D) will learn how to use Hapi for his own use cases. |
@zoe-1 you are a diplomatic man ^^ I like how you suggested people could do the moving of the plugin as an extra exercise
|
Hi @zoe-1 good job with new assignment and I like the roadmap, will be submitting a PR soon 👍 |
@hussainanjar Glad you like the assignment. Look forward to seeing your PR :-) |
@AdriVanHoudt and community, in response to @AdriVanHoudt questions and recommendations, I edited the assignment to clarify things and answer the questions. Thank you @AdriVanHoudt for the feedback! It is always good to have another set of eyes look things over. In response to, no indication of what the home plugin should give back:
In response to the glue testing question, can we have 100% cc with that?Yes, we can get 100% coverage. glue and lab play well together. But, we will have to refactor our tests to make it happen. In response to making a label about discussion for next assignmentsYes, good idea. Plan to do it. In response to adding a check part to the assignment.That is a good idea :-) I will change it soon. Why I chose not refactor the auth plugin registration myself after the assignment:
|
Thanks for all the work @zoe-1 |
@zoe-1 Nice work with the assignment. I mostly agree with your points however I'd have two remarks:
|
@AdriVanHoudt I think its better if I get to do the cleanup rather then someone doing on my behalf. It helps you learn best practices |
Can't you pass an array to glue? On Sun, 24 May 2015 06:52 Hussain Fakhruddin [email protected]
|
@AdriVanHoudt Nope, in its current state Glue won't take an array for plugins, it iterates over them using directly Object.keys on the property and using each key to resolve the plugin. |
@AdriVanHoudt In respect to the make file, I put the refactor in the assignment so everyone would see that hapijs style requirements were modified for the whole hapijs community. @FennNaten in respect to your question about Glue and the order of plugins being registered, based upon my experience and testing, Glue registers the plugins in the order you place them in the manifest file. If you put the auth plugin registration configs at the bottom of Glue's plugin registry, this results in registration failure. However, if you place auth plugins first in the plugins section of manifest.js like the (aqua project)[https://github.com/jedireza/aqua/blob/master/manifest.js] everything works fine. Later Comment Addition Below:Sorry, I answered this question too fast. Just saw you started an issue at aqua repo about this. jedireza/aqua#36
|
Assignment Due May 30th.@FennNaten thank you for the due date reminder :-) |
@zoe-1 : about the order of plugins registration, it's more of a remark than a question ;) Replication of the issue is hard to do, I won't say it's random because it's not really, but it depends on how V8 engine 'decides' to optimize the code being executed. Most of the time, object keys are kept in the order they're inserted, and everything is fine. However, this is not a fact to take for granted, as ECMAScript spec doesn't guarantee insertion order preservation for object keys. |
@FennNaten It seems @Marsup refers to the solution to the plugin load order at: hapijs/glue#19 (you referenced this issue above). Looks like we need a JSON schema requiring dependecies to be loaded before plugins that depend on them are loaded. Or, we need to declare dependencies the glue way. But, I have never seen a real world example of glue doing this and the glue docs don't make any mention to it. But, @Marsup implies it is possible and that would seem to be the way to bullet proof the code. |
@zoe-1 Yes, that's what I was saying in my original remark ;)
However I still have to make tests to see what works and what doesn't. Was planning to do them while working on optional part on the assignment |
@FennNaten Sometimes I have to read things a couple times before I actually read them LOL ;) |
@FennNaten Got feedback from @Marsup on gitter. He said to use: |
@zoe-1 I just added a home plugin and brought back 100% test coverage, I'll do some tests with dependencies while completing optional assignement, to be sure that works as expected. Speaking of tests, in the assignment you say
Glue uses CPS and actually bubbles up registration errors, if we follow the same pattern we've been using (with index.js exposing an init method taking the manifest and options as params + a callback with signature |
@FennNaten In respect to your observations about Glue using CPS (Continual Passing Style), and registration errors, it would be great to have our project test the success or failure of plugins loading just as we did before. Thank you for sharing your observations and knowledge. You are making the quality of our assignment improve! I look forward to seeing your PR. |
@zoe-1 You're welcome, I just try to do my part ;) |
@zoe-1 maybe start a thread about the next assignment? Also not much On Thu, 28 May 2015 22:24 Jon Swenson [email protected] wrote:
|
@AdriVanHoudt good recommendations. |
OK cool and I'll see where it can fit on the website On Fri, 29 May 2015 02:14 Eran Hammer [email protected] wrote:
|
@hueniverse and community, below is a potential assignment to keep the project moving.
@hueniverse Hopefully, you will find this acceptable. Your feedback would be appreciated.
This should build off previous assignments and move us one step forward to master the learning objectives described at: https://github.com/zoe-1/hapitimes.
Community your feedback would be appreciated too.
[Assignment 5] Glue and HTML views
Glue should be used to load all plugins.
Note about hapi-auth-basic:
hapi-auth-basic plugin is registered.
Glue will reference this file in the manifest file to load the plugin.
the root path of the application. For now, just make html pages for view files (no .hbs files).
the other called "version", and one called "private". Each point is located in it's own plugin
which glue composes when the server starts up.
Hints:
Sample Manifest JSON object
Due Date: May 28th 2015.
The text was updated successfully, but these errors were encountered: