foxx apps dev workflow

235 views
Skip to first unread message

Szczepan Bednarz

unread,
Dec 12, 2013, 7:15:58 AM12/12/13
to aran...@googlegroups.com
Hi,
I’d ask advanced Users about hints how to develop Foxx apps.
How to use ArangoDB tools in this process (planning, testing, debugging)? Just a few general hints for C++/perl/ruby programmer without deep javascript knowledge ;)

Best regards,
Szczepan

Michael Hackstein

unread,
Dec 12, 2013, 5:23:40 PM12/12/13
to aran...@googlegroups.com
Hi Szczepan,

i hope i can give you some anchor points with the following hints:
* Planning (Exactly the same procedure as for all other REST-Servers, if you did write one already skip this ;) )
  * For a Foxx App you have to consider the following points:
  * Which information demand has my web page (e.g. you have a list of users and you want some server-side filtering)
  * How to transform this demand into Rest routes (you may know this already if you have created Rails server)
    * especially consider the requirements of your frontend framework here, most of them automatically create requests e.g. a Collection in Backbone.js can be given a root url (e.g. "/users" and the framework will then create following requests:
      * GET /users -> Fetch the entire list
      * POST /users -> Store a new user
      * PUT /users/userid -> Update a user
      * DELETE /users/userid -> Delete a user
    * try to be conform to these frameworks, makes your life easier at the end
  * Take into account if you want your app to access global collections (some existing data-source or a shared data-source) or if the data should be local to the App only.
    * This point changes the way you have to create a repository in Foxx, it is a minor change but may cause confusion later on.

* Testing
  * There is no dedicated test framework for Foxx (yet)
  * As you are a Ruby programmer i would suggest to test the REST API with help of HTTParty (or other useful Ruby libraries you have more experience there than i have ;) )
  * For these tests:
    * define a test database with all necessary test datasets.
    * Use arangodump to persist it somewhere.
    * Execute your test the following way:
      * Start an arranged pointing to an empty data directory
      * execute arangoimp to import the test data created above
      * execute your tests
      * shutdown arangod and remove the data directory
  * Alternatively you could use javascript test frameworks (like jasmine or jsunity) and create mocks for server communication (so you catch the outgoing request and return a specified test value)
    * This gives the benefit that you do not have to start arangod and you can unit-test your app only.
    * "Drawback", you have to learn some javascript ;)

* Debugging
  * if you start arangod with —log.file + the logging information will be printed to the screen.
  * For debugging you will then get the stack trace (if something breaks you will get two errors, the first error is important for you as it tells you where in the foxx app the crash occurs, the second error is internal as arangodb could not process the broken result from above)
  * If you just want to play around with server-side commands (independent of what Foxx adds, like the repositories or models) you can start arangod —console
    * This will start an emergency console for arangodb which has exactly the same context as your foxx app has, so what ever is available here will also be available in foxx.
    * Then you can just play around with some commands and fine-tune your result and copy the created lines to foxx (recommended for very short sequences only, for a larger sequence look below)
  * Furthermore you can just print out any variable in the log.file (or stdout with log.file +) by using require("console“).log(…) this will help to drill down false values that do not cause a crash.


But let me add some additional points that you might find useful:
* Development Mode
  * arangod can be started with " --javascript.dev-app-path /some/path " expecting a folder with the subfolder database/_system/<yourfoxxapp>. Then your App will be automatically available at localhost:8529/dev/yourfoxxapp and will automatically be reloaded each request.
  * Using this you can immediately see changes in your code applied without the need to uninstall/install the app again and again.

* Production Mode
  * In production mode (which you will get when using foxx-manager install) the app will only be loaded once and than cached, so changes in the source code will not be considered until reinstalling the app.
  * This gives you a large performance benefit compared to development mode

if you need some further advice feel free to contact me
best
Michael


--
You received this message because you are subscribed to the Google Groups "ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arangodb+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Patrick Mulder

unread,
Dec 12, 2013, 6:03:49 PM12/12/13
to aran...@googlegroups.com
Hi Szczepan,

what I found is that the live-reload of the development mode helps a lot. 

What I did with Foxx so far, was building a mapping ("schema"), on top of the "schemaless" collections. The ideas here are very similar to Backbone.js, and it woudl certainly interesting to me, if you report back what you find here, when you play with this.

As far as I hear, there is a lot planned for Foxx. Most things right now, are mainly addressing the basic CRUD operations as Michael described.

Maybe this helps,

Patrick

Szczepan Bednarz

unread,
Dec 12, 2013, 7:15:44 PM12/12/13
to aran...@googlegroups.com
Hi,

Thank you Michael and Patrick for your fast and valuable replies.
Now I'm ready to start playing  with Foxx.

regards
sz.

Jordi Aranda

unread,
Dec 2, 2014, 5:32:05 AM12/2/14
to aran...@googlegroups.com
Any updates concerning Foxx apps testing?

Lucas Dohmen

unread,
Dec 5, 2014, 7:37:33 AM12/5/14
to aran...@googlegroups.com
Hi Jorda,

Unfortunately not. But I will discuss this topic again with Alan and Frank so we can put it onto our roadmap :)

Best Wishes
Lucas

Ajay Sonune

unread,
Aug 9, 2017, 7:50:45 AM8/9/17
to ArangoDB
hello everyone,
                    I am new with arangodb foxx microservices.
so can i got to know that how to use dev-mode for foxx-services with arangodb version 3.0
 
 
Reply all
Reply to author
Forward
0 new messages