Imported test server.
authorTomas Zeman <tzeman@volny.cz>
Sat, 14 Dec 2013 21:40:24 +0100
changeset 1 411d80fcd66c
parent 0 a195fd765a7f
child 2 26148011541f
Imported test server.
LICENSE
package.coffee
package.json
server.coffee
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE	Sat Dec 14 21:40:24 2013 +0100
@@ -0,0 +1,16 @@
+Copyright 2013 Tomas Zeman <tzeman@volny.cz>. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package.coffee	Sat Dec 14 21:40:24 2013 +0100
@@ -0,0 +1,15 @@
+p =
+  name: 'asa-test-server'
+  version: '1.1.0'
+  description: 'Test server for A.S.A. app'
+  dependencies:
+    bunyan: '~0.22.1'
+    'coffee-script': "~1.6.3"
+    collections: "~0.2.0"
+    q: "~0.9.7"
+    'q-io': "~1.10.3"
+       
+
+console.log JSON.stringify(p, null, "  ")
+
+# vim: et ts=2 sw=2 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package.json	Sat Dec 14 21:40:24 2013 +0100
@@ -0,0 +1,12 @@
+{
+  "name": "asa-test-server",
+  "version": "1.1.0",
+  "description": "Test server for A.S.A. app",
+  "dependencies": {
+    "bunyan": "~0.22.1",
+    "coffee-script": "~1.6.3",
+    "collections": "~0.2.0",
+    "q": "~0.9.7",
+    "q-io": "~1.10.3"
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server.coffee	Sat Dec 14 21:40:24 2013 +0100
@@ -0,0 +1,41 @@
+Q = require 'q'
+Http = require 'q-io/http'
+Apps = require 'q-io/http-apps'
+bunyan = require 'bunyan'
+
+log = bunyan.createLogger {
+  name: 'asa-test-server'
+  level: 'debug'
+}
+
+route = Apps.Branch {
+  'ok': (rq,rs) => {
+    status: 200
+    headers: {}
+    data:
+      result: 'ok'
+      request:
+        path: rq.path
+        pathInfo: rq.pathInfo
+      response: rs
+  }
+  'post': Apps.Method {
+    'POST': new Apps.Chain().use(Apps.JsonRequest).use(() => (o, rq, rs) => {
+      status: 200
+      headers: {}
+      data:
+        post: o
+        request:
+          path: rq.path
+          pathInfo: rq.pathInfo
+        response: rs
+    }).end()
+  }, Apps.methodNotAllowed
+}
+
+app = Apps.Chain().use(() => Apps.HandleJsonResponses(route, null, "  "))
+  .end()
+
+Http.Server(app).listen(3000)
+
+# vim: et ts=2 sw=2