1
0
Fork 0

Adjusted Aardvark to new version of Foxx

This commit is contained in:
Lucas Dohmen 2013-09-04 10:51:14 +02:00
parent afef07b425
commit 94a151ec2f
1 changed files with 12 additions and 12 deletions

View File

@ -2,7 +2,7 @@
/*global require, applicationContext*/ /*global require, applicationContext*/
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief A Foxx-Application to overview your Foxx-Applications /// @brief A Foxx.Controller to show all Foxx Applications
/// ///
/// @file /// @file
/// ///
@ -30,9 +30,9 @@
"use strict"; "use strict";
// Initialise a new FoxxApplication called app under the urlPrefix: "foxxes". // Initialise a new FoxxController called controller under the urlPrefix: "foxxes".
var FoxxApplication = require("org/arangodb/foxx").Application, var FoxxController = require("org/arangodb/foxx").Controller,
app = new FoxxApplication(applicationContext), controller = new FoxxController(applicationContext),
underscore = require("underscore"); underscore = require("underscore");
var foxxes = new (require("lib/foxxes").Foxxes)(); var foxxes = new (require("lib/foxxes").Foxxes)();
@ -42,7 +42,7 @@ var docus = new (require("lib/swagger").Swagger)();
// install // install
// ............................................................................. // .............................................................................
app.put("/foxxes/install", function (req, res) { controller.put("/foxxes/install", function (req, res) {
var content = JSON.parse(req.requestBody), var content = JSON.parse(req.requestBody),
name = content.name, name = content.name,
mount = content.mount, mount = content.mount,
@ -55,7 +55,7 @@ app.put("/foxxes/install", function (req, res) {
// uninstall // uninstall
// ............................................................................. // .............................................................................
app.del("/foxxes/:key", function (req, res) { controller.del("/foxxes/:key", function (req, res) {
res.json(foxxes.uninstall(req.params("key"))); res.json(foxxes.uninstall(req.params("key")));
}).pathParam("key", { }).pathParam("key", {
description: "The _key attribute, where the information of this Foxx-Install is stored.", description: "The _key attribute, where the information of this Foxx-Install is stored.",
@ -69,7 +69,7 @@ app.del("/foxxes/:key", function (req, res) {
// update // update
// ............................................................................. // .............................................................................
app.put("/foxxes/:key", function (req, res) { controller.put("/foxxes/:key", function (req, res) {
var content = JSON.parse(req.requestBody), var content = JSON.parse(req.requestBody),
active = content.active; active = content.active;
// TODO: Other changes applied to foxx! e.g. Mount // TODO: Other changes applied to foxx! e.g. Mount
@ -90,7 +90,7 @@ app.put("/foxxes/:key", function (req, res) {
// read thumbnail // read thumbnail
// ............................................................................. // .............................................................................
app.get("/foxxes/thumbnail/:app", function (req, res) { controller.get("/foxxes/thumbnail/:app", function (req, res) {
res.transformations = [ "base64decode" ]; res.transformations = [ "base64decode" ];
res.body = foxxes.thumbnail(req.params("app")); res.body = foxxes.thumbnail(req.params("app"));
}).pathParam("app", { }).pathParam("app", {
@ -105,7 +105,7 @@ app.get("/foxxes/thumbnail/:app", function (req, res) {
// all foxxes // all foxxes
// ............................................................................. // .............................................................................
app.get('/foxxes', function (req, res) { controller.get('/foxxes', function (req, res) {
res.json(foxxes.viewAll()); res.json(foxxes.viewAll());
}).summary("List of all foxxes.") }).summary("List of all foxxes.")
.notes("This function simply returns the list of all running foxxes"); .notes("This function simply returns the list of all running foxxes");
@ -114,7 +114,7 @@ app.get('/foxxes', function (req, res) {
// documentation for all foxxes // documentation for all foxxes
// ............................................................................. // .............................................................................
app.get('/docus', function (req, res) { controller.get('/docus', function (req, res) {
res.json(docus.list("http://" + req.headers.host + req.path + "/")); res.json(docus.list("http://" + req.headers.host + req.path + "/"));
}).summary("List documentation of all foxxes.") }).summary("List documentation of all foxxes.")
.notes("This function simply returns the list of all running" .notes("This function simply returns the list of all running"
@ -124,7 +124,7 @@ app.get('/docus', function (req, res) {
// documentation for one foxx // documentation for one foxx
// ............................................................................. // .............................................................................
app.get("/docu/:key",function (req, res) { controller.get("/docu/:key",function (req, res) {
var subPath = req.path.substr(0,req.path.lastIndexOf("[")-1), var subPath = req.path.substr(0,req.path.lastIndexOf("[")-1),
key = req.params("key"), key = req.params("key"),
path = "http://" + req.headers.host + subPath + "/" + key + "/"; path = "http://" + req.headers.host + subPath + "/" + key + "/";
@ -137,7 +137,7 @@ app.get("/docu/:key",function (req, res) {
// API for one foxx // API for one foxx
// ............................................................................. // .............................................................................
app.get('/docu/:key/*', function(req, res) { controller.get('/docu/:key/*', function(req, res) {
var mountPoint = ""; var mountPoint = "";
underscore.each(req.suffix, function(part) { underscore.each(req.suffix, function(part) {
mountPoint += "/" + part; mountPoint += "/" + part;