Skip to content

Instantly share code, notes, and snippets.

Last active Mar 9, 2016
What would you like to do?
sample: ArangoDB's Foxx controller with using any library you want
(function() {
"use strict";
var Foxx = require("org/arangodb/foxx"),
controller = new Foxx.Controller(applicationContext),
_ = require("underscore"), // loading underscore.js in C:\Program Files\ArangoDB 2.2.4\share\arangodb\js\node\node_modules
moment = require("moment"); // loading moment.js in C:\Program Files\ArangoDB 2.2.4\share\arangodb\js\node\node_modules
controller.get("/hello/:name", function(req, res) {
res.set("Content-Type", "text/plain");
res.body = "Hello " + req.params("name");
// If your Foxx app is deployed to 'http://localhost:8529/dev/my_app/',
// put the url 'http://localhost:8529/dev/my_app/momentSample' then you'll get a result of the now time as JSON.
controller.get("/momentSample", function(req, res) {
var result = "";
if (_.isObject(moment)) { // enable to use underscore functions.
result = "Result of moment function: " + moment().format("YYYY-MM-DD hh:mm"); // enable to use moment functions.
res.json({ result: result });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment