# HG changeset patch # User Tomas Zeman # Date 1387123897 -3600 # Node ID cbba85b1f677fd4f5ad4cb2d20a4e85c3b28e97d # Parent 0fa2f12fcb3cf11fe20f518a494aaaf067e1a649 /orders, /event, /ping, /log diff -r 0fa2f12fcb3c -r cbba85b1f677 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()