Skip to content

Commit

Permalink
Merge pull request #41 from electricimp/develop
Browse files Browse the repository at this point in the history
CSE-741 (Add singleton)
  • Loading branch information
betzrhodes authored Dec 12, 2019
2 parents 426eca7 + 22eb7cd commit ec56ee7
Show file tree
Hide file tree
Showing 15 changed files with 1,887 additions and 943 deletions.
4 changes: 2 additions & 2 deletions .impt.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"*.test.nut",
"tests/**/*.test.nut"
],
"agentFile": "Rocky.class.nut"
}
"agentFile": "Rocky.agent.lib.nut"
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Electric Imp
Copyright (c) 2015-19 Electric Imp

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 7 additions & 3 deletions Middleware-Example/middlewareExample.agent.nut
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#require "rocky.class.nut:2.0.0"
// Copyright (c) 2015-19 Electric Imp
// This file is licensed under the MIT License
// http://opensource.org/licenses/MIT

#require "Rocky.agent.lib.nut:3.0.0"

// Dummy Data for API
data <- { "foo": "bar" };
Expand All @@ -17,7 +21,7 @@ function debugMiddleware(context, next) {

// Middleware to add CORS headers
function CORSMiddleware(context, next) {
server.log("Adding CORS headers to request")
server.log("Adding CORS headers to request");

// Add some headers
context.setHeader("Access-Control-Allow-Origin", "*");
Expand All @@ -29,7 +33,7 @@ function CORSMiddleware(context, next) {
}

// Setup Rocky and use the debugMiddleware on ALL requests
app <- Rocky().use([ debugMiddleware ]);
app <- Rocky.init().use([ debugMiddleware ]);

// GET / - send hello world
app.get("/", function(context) {
Expand Down
813 changes: 615 additions & 198 deletions README.md

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions RGBLed-Example/rgb.agent.nut
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2015 Electric Imp
// Copyright (c) 2015-19 Electric Imp
// This file is licensed under the MIT License
// http://opensource.org/licenses/MIT

#require "Rocky.class.nut:2.0.0"
#require "Rocky.agent.lib.nut:3.0.0"

/******************** Application Code ********************/
led <- {
Expand All @@ -14,7 +14,7 @@ device.on("info", function(data) {
led = data;
});

app <- Rocky();
app <- Rocky.init();

app.get("/color", function(context) {
context.send(200, { color = led.color });
Expand All @@ -32,7 +32,8 @@ app.post("/color", function(context) {

// if preflight check passed - do things
led.color = context.req.body.color;
device.send("setColor", context.req.body.color);
server.log("Setting color to R: " + led.color.red + ", G: " + led.color.green + ", B: " + led.color.blue);
device.send("setColor", led.color);

// send the response
context.send({ "verb": "POST", "led": led });
Expand All @@ -53,7 +54,8 @@ app.post("/state", function(context) {

// if preflight check passed - do things
led.state = context.req.body.state;
device.send("setState", context.req.body.state);
server.log("Setting state to " + (led.state ? "on" : "off"));
device.send("setState", led.state);

// send the response
context.send({ "verb": "POST", "led": led });
Expand Down
2 changes: 1 addition & 1 deletion RGBLed-Example/rgb.device.nut
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015 Electric Imp
// Copyright (c) 2015-19 Electric Imp
// This file is licensed under the MIT License
// http://opensource.org/licenses/MIT

Expand Down
Loading

0 comments on commit ec56ee7

Please sign in to comment.