You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
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
require('./version') should be declared at the top and assigned to Version`.
no need to wrap the plugin in { register: Version }. It is enough to just pass Version directly to the register() function.
no need for specifying the plugin version in the attributes. This is an internal plugin, not a publicly published one.
[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 pluginregister()
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 theissue 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
require('./version') should be declared at the top and assigned to
Version`.{ register: Version }
. It is enough to just pass Version directly to theregister()
function.source for Helps: Discussion between @hueniverse and @thealphanerd.
Original Assignment2
Assignment2 Solution
The text was updated successfully, but these errors were encountered: