Permalink
Browse files

Add index.js.

  • Loading branch information...
1 parent 9cfb932 commit aa75f0d2b5aa87fbfae095d86c5240ae234abebf @mbostock mbostock committed Sep 15, 2011
File renamed without changes.
View
@@ -0,0 +1,9 @@
+var options = require("./collector-config"),
+ cube = require("../"),
+ server = cube.server(options);
+
+server.register = function(db, endpoints) {
+ cube.collector.register(db, endpoints);
+};
+
+server.start();
File renamed without changes.
View
@@ -0,0 +1,10 @@
+var options = require("./evaluator-config"),
+ cube = require("../"),
+ server = cube.server(options);
+
+server.register = function(db, endpoints) {
+ cube.evaluator.register(db, endpoints);
+ cube.visualizer.register(db, endpoints);
+};
+
+server.start();
@@ -1,5 +1,5 @@
var util = require("util"),
- emitter = require("../../../lib/cube/server/emitter"),
+ cube = require("../../../"),
options = require("./random-config"),
count = 0,
batch = 10,
@@ -9,7 +9,7 @@ var util = require("util"),
// Connect to websocket.
util.log("starting websocket client");
-var client = emitter().open(options["http-host"], options["http-port"]);
+var client = cube.emitter().open(options["http-host"], options["http-port"]);
// Emit random values.
var interval = setInterval(function() {
View
@@ -0,0 +1,5 @@
+exports.emitter = require("./server/emitter");
+exports.server = require("./server/server");
+exports.collector = require("./server/collector");
+exports.evaluator = require("./server/evaluator");
+exports.visualizer = require("./server/visualizer");
@@ -1,8 +1,6 @@
-var options = require("../../../config/collector"),
- server = require("./server")(options),
- endpoint = require("./endpoint");
+var endpoint = require("./endpoint");
-server.register = function(db, endpoints) {
+exports.register = function(db, endpoints) {
var putter = require("./event").putter(db);
endpoints.ws.push(
endpoint.exact("/1.0/event/put", putter)
@@ -38,5 +36,3 @@ function post(putter) {
});
};
}
-
-server.start();
@@ -1,6 +1,7 @@
var fs = require("fs"),
url = require("url"),
- path = require("path");
+ path = require("path"),
+ cube = require("../");
exports.re = re;
exports.exact = exact;
@@ -74,7 +75,7 @@ function file() {
};
function resolve(name) {
- return path.join(process.cwd(), name);
+ return path.join(__dirname, name);
}
function fiveohoh(request, response) {
@@ -1,14 +1,8 @@
-var options = require("../../../config/evaluator"),
- server = require("./server")(options),
- endpoint = require("./endpoint"),
- visualizer = require("./visualizer");
+var endpoint = require("./endpoint");
-server.register = function(db, endpoints) {
+exports.register = function(db, endpoints) {
endpoints.ws.push(
endpoint.exact("/1.0/event/get", require("./event").getter(db)),
endpoint.exact("/1.0/metric/get", require("./metric").getter(db))
);
- visualizer.register(db, endpoints);
};
-
-server.start();
@@ -9,28 +9,28 @@ exports.register = function(db, endpoints) {
endpoint.exact("/", createBoard(db)),
endpoint.re(/^\/[0-9][0-9a-z]{5}(\/edit)?$/, loadBoard(db)),
endpoint.exact("/cube.js", endpoint.file(
- "lib/cube/client/start.js",
- "lib/cube/client/cube.js",
- "lib/cube/client/piece.js",
- "lib/cube/client/piece-area.js",
- "lib/cube/client/piece-sum.js",
- "lib/cube/client/piece-text.js",
- "lib/cube/client/palette.js",
- "lib/cube/client/squares.js",
- "lib/cube/client/board.js",
- "lib/cube/client/header.js",
- "lib/cube/client/end.js"
+ "../client/start.js",
+ "../client/cube.js",
+ "../client/piece.js",
+ "../client/piece-area.js",
+ "../client/piece-sum.js",
+ "../client/piece-text.js",
+ "../client/palette.js",
+ "../client/squares.js",
+ "../client/board.js",
+ "../client/header.js",
+ "../client/end.js"
)),
endpoint.exact("/cube.css", endpoint.file(
- "lib/cube/client/body.css",
- "lib/cube/client/palette.css",
- "lib/cube/client/board.css",
- "lib/cube/client/piece.css"
+ "../client/body.css",
+ "../client/palette.css",
+ "../client/board.css",
+ "../client/piece.css"
)),
endpoint.exact("/d3/d3.js", endpoint.file(
- "node_modules/d3/d3.min.js",
- "lib/cube/client/semicolon.js",
- "node_modules/d3/d3.time.min.js"
+ "../../../node_modules/d3/d3.min.js",
+ "../client/semicolon.js",
+ "../../../node_modules/d3/d3.time.min.js"
))
);
};
@@ -61,7 +61,7 @@ function createBoard(db) {
function loadBoard(db) {
var boards,
- file = endpoint.file("lib/cube/client/visualizer.html");
+ file = endpoint.file("../client/visualizer.html");
db.collection("boards", function(error, collection) {
boards = collection;
View
@@ -1,6 +1,7 @@
{
"name": "cube",
"version": "0.0.1",
+ "main": "./lib/cube",
"dependencies": {
"d3": "2.1.3",
"mongodb": "0.9.6-15",

0 comments on commit aa75f0d

Please sign in to comment.