Browse Source

Implement Oak framework (#4868)

Mike Smith 6 years ago
parent
commit
a79a69801e

+ 23 - 0
frameworks/TypeScript/oak/README.md

@@ -0,0 +1,23 @@
+# Oak Benchmarking Test
+
+### Test Type Implementation Source Code
+
+- [JSON](src/index.ts)
+- [PLAINTEXT](src/index.ts)
+
+## Important Libraries
+
+The tests were run with:
+
+- [Deno](https://deno.land/)
+- [Oak](https://github.com/oakserver/oak)
+
+## Test URLs
+
+### JSON
+
+http://localhost:8000/json
+
+### PLAINTEXT
+
+http://localhost:8000/plaintext

+ 26 - 0
frameworks/TypeScript/oak/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "oak",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "port": 8000,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "None",
+        "framework": "Oak",
+        "language": "TypeScript",
+        "flavor": "Deno",
+        "orm": "None",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "Oak",
+        "notes": "",
+        "versus": "nodejs"
+      }
+    }
+  ]
+}

+ 6 - 0
frameworks/TypeScript/oak/oak.dockerfile

@@ -0,0 +1,6 @@
+FROM maxmcd/deno
+
+WORKDIR /home
+COPY src src
+
+CMD ["deno", "--allow-net", "./src/index.ts"]

+ 23 - 0
frameworks/TypeScript/oak/src/index.ts

@@ -0,0 +1,23 @@
+import { Application, Router } from "https://deno.land/x/oak/mod.ts";
+
+(async () => {
+  const router = new Router();
+
+  router
+    .get("/json", context => {
+      context.response.headers.set("Server", "Oak");
+      context.response.headers.set("Date", new Date().toUTCString());
+      context.response.body = { message: "Hello, World!" };
+    })
+    .get("/plaintext", context => {
+      context.response.headers.set("Server", "Oak");
+      context.response.headers.set("Date", new Date().toUTCString());
+      context.response.body = "Hello, World!";
+    });
+
+  const app = new Application();
+  app.use(router.routes());
+  app.use(router.allowedMethods());
+
+  await app.listen("0.0.0.0:8000");
+})();