/orders, /event, /ping, /log
authorTomas Zeman <tzeman@volny.cz>
Sun, 15 Dec 2013 17:11:37 +0100
changeset 4 cbba85b1f677
parent 3 0fa2f12fcb3c
child 5 ed2abdd11a1b
/orders, /event, /ping, /log
server.coffee
--- a/server.coffee	Sat Dec 14 21:58:38 2013 +0100
+++ b/server.coffee	Sun Dec 15 17:11:37 2013 +0100
@@ -8,7 +8,12 @@
   level: 'debug'
 }
 
+noContent =
+  status: 204
+  headers: {}
+
 route = Apps.Branch {
+  ###
   'ok': (rq,rs) => {
     status: 200
     headers: {}
@@ -31,7 +36,8 @@
         response: rs
     })
   }, Apps.methodNotAllowed
-
+  ###
+ 
   'login': Apps.Method {
     'POST': Apps.JsonRequest((o, rq, rs) =>
       log.info("Login", o)
@@ -42,7 +48,49 @@
           configId: 'cfg1'
           sessionId: 'sess1'
       })
+  }, Apps.methodNotAllowed
+
+  'orders': (rq, rs) => {
+    status: 200
+    headers: {}
+    data:
+      orders: [{
+          orderId: 123
+          name: 'Order 1'
+          description: 'Description of order 1'
+        }, {
+          orderId: 554
+          name: 'Order 2'
+          description: 'Description of order 2'
+        }]
   }
+
+  'event': Apps.Method {
+    'POST': Apps.JsonRequest((o, rq, rs) =>
+      log.info("Event", o)
+      noContent
+    )
+  }, Apps.methodNotAllowed
+
+  'ping': Apps.Method {
+    'POST': Apps.JsonRequest((o, rq, rs) =>
+      log.info("Ping", o)
+      noContent
+    )
+  }, Apps.methodNotAllowed
+
+  'log': Apps.Method {
+    'POST': Apps.JsonRequest((o, rq, rs) =>
+      log.info("Ping", o)
+      noContent
+    )
+    'GET': (rq, rs) => {
+      status: 200
+      headers: {}
+      data:
+        lastLog: new Date().toISOString()
+    }
+  }, Apps.methodNotAllowed
 }
 
 app = Apps.Chain()