The Event Handler must be defined in your application.ffdl file that is in the ff-config directory that was created for you during scaffolding. See FatFractal Definition Language (here) for more information.
The download of the project for Tutorial Part 4 also includes the files that were generated for you by the scaffolding process so that you can see what the application.ffdl looks like at the end of the Tutorial.
In the FFDL code we do two things:
CREATE HANDLER WouldYaCreate POST ON /WouldYa Create as javascript:var h = require ('scripts/WouldYaEventHandlers'); h.handleWouldYaCreate (FF_EVENT_DATA_JSON);
This entry tells the NoServer Framework to create an event on WouldYa Create, and execute the handleWouldYaCreate function that is in WouldYaEventHandlers.js file passing in the event data.
This gives us another example of the power of NoServer APIs. We are now going to create another COLLECTION called TopCelebrity which will be of OBJECTYPE Celebrity. This allows us to easily reuse our object models for other purposes. This new resource will keep track of the top rated celebrity over time.
Since we have already defined the OBJECTTYPE Celebrity in Part1, we can just reuse that class here (hey - ain’t code reuse wonderful?). We add this to our application.ffdl file.
CREATE COLLECTION /TopCelebrity OBJECTTYPE Celebrity
This entry tells the NoServer Framework to create a new COLLECTION called TopCelebrity that will use the existing OBJECTTYPE defined earlier - the Celebrity.
To make your API aware of these new items, you need to deploy again (have you noticed how little you have to fiddle around with your API so far??) by doing the following:
If you haven't already, go to the Console and add an application called hoodyoodoo to <your subdomain>. From the hoodyoodoo application directory, deploy the modified hoodyoodoo API to the NoServer Public Cloud, you use the command line deployFFFabric:
> $HOME/ff/ffnsbin/ffef deployFFFabric
In a few seconds, your updated application will be available at http://<your subdomain>.fatfractal.com/hoodyoodoo
Assuming that the FatFractal Engine is running, you can also deploy to your development machine using the command line deploylocal:
> $HOME/ff/ffnsbin/ffef deploylocal
In a few seconds, your modified application will be available at http://localhost:8080/hoodyoodoo