Permalink
Browse files

Add dummy data test server

  • Loading branch information...
stewart committed Apr 1, 2015
1 parent 57ac9ab commit c15336bfd0288d393dd0f334636699a9348f466d
Showing with 106 additions and 1 deletion.
  1. +1 −0 .npmignore
  2. +5 −1 Makefile
  3. +2 −0 package.json
  4. +98 −0 script/dev-server.js
View
@@ -1,2 +1,3 @@
src
spec
script
View
@@ -10,6 +10,7 @@ help:
@echo ""
@echo " make clean - removes built files"
@echo " make lint - runs JSXHint against src/javascripts"
@echo " make serve - run development server with dummy data on :3000"
@echo " make js - builds JavaScript with Browserify"
@echo " make css - builds CSS with Sass"
@echo " make watch-js - watches/builds JavaScript with Browserify"
@@ -56,4 +57,7 @@ minified: clean
test:
@$(BIN)mocha --colors -R dot $(TEST_FILES)
.PHONY: help lint css js watch-js watch-css clean all minified test
serve:
@node ./script/dev-server.js
.PHONY: help lint css js watch-js watch-css clean all minified test serve
View
@@ -19,6 +19,8 @@
"watchify": "3.1.0",
"eslint": "0.18.0",
"express": "4.12.3",
"superagent": "1.1.0",
"react": "0.13.1",
"react-router": "0.13.2",
View
@@ -0,0 +1,98 @@
var express = require('express');
var app = express();
app.use(express["static"](require("path").resolve(__dirname + "/../")));
app.use(function(req, res, next) {
res.set("Access-Control-Allow-Origin", this.CORS || "*");
res.set("Access-Control-Allow-Headers", "Content-Type");
res.set("Content-Type", "application/json");
if (req.method === "OPTIONS") {
return res.sendStatus(200);
}
return next();
});
app.get('/api', function (req, res) {
res.send({ MCP: MCP });
});
app.listen(3000)
// dummy data to send to the client
var MCP = {
commands: [ "echo" ],
events: [ "robot_added", "robot_removed" ],
robots: [
{
commands: [ "hello" ],
connections: [
{
adaptor: "Loopback",
details: {
port: "/dev/null",
test: "abc"
},
name: "loopback"
}
],
devices: [
{
commands: [ "ping", "otherPing", "aThirdThing" ],
connection: "loopback",
details: {
pin: "13",
test: "abc"
},
driver: "Ping",
events: [ "ping" ],
name: "ping"
},
{
commands: ["cmd1", "cmd2", "cmd3"],
connection: "loopback",
details: {
pin: "13",
test: "abc"
},
driver: "Ping",
events: [ "ping" ],
name: "ping-2"
}
],
events: [ "hello" ],
name: "TestBot"
},
{
commands: [ "hello" ],
connections: [
{
adaptor: "Loopback",
details: {
port: "/dev/null",
test: "abc"
},
name: "loopback"
}
],
devices: [
{
commands: [ "ping" ],
connection: "loopback",
details: {
pin: "13",
test: "abc"
},
driver: "Ping",
events: [ "ping" ],
name: "ping"
}
],
events: [ "hello" ],
name: "TestBot-1"
}
]
};

0 comments on commit c15336b

Please sign in to comment.