outmoded / university

Community learning experiment
Other
371 stars 193 forks source link

v0.1.2 assignment2 Plugins #262

Closed zoe-1 closed 6 years ago

zoe-1 commented 6 years ago

[Assignment2] Plugins

The right way to work with hapi is to build your application using plugins. Plugins provide a way to organize your code into logical components and then put them together in different combinations or deploy them in different configurations. While some plugins are published as general purpose utilities (e.g. adding authentication), you should think of plugins as a way to break your code into pieces.

Now that we have a basic server with one endpoint, we want to move the creation of the endpoint to a plugin, and then register that plugin with the server. Creating a new file lib/version.js and move the /version endpoint there, wrapped in the plugin register() function.

Then change our current lib/index.js to require the new file and register the version plugin with our server. Remember to follow the style guide, and ask any questions in the comments of the issue created for the assignment. If you are not sure how to get your fork back in sync with the current updated code, use the git guide.

Helps

source for Helps: Discussion between @hueniverse and @TheAlphaNerd. Original Assignment2

Assignment2 Solution