Browse Source

Add Dart Frog Framework (#10048)

Felix Angelov 1 month ago
parent
commit
222d7a1222

+ 9 - 0
frameworks/Dart/dart_frog/.dockerignore

@@ -0,0 +1,9 @@
+# From https://hub.docker.com/_/dart
+.dockerignore
+Dockerfile
+build/
+.dart_tool/
+.git/
+.github/
+.gitignore
+.packages

+ 6 - 0
frameworks/Dart/dart_frog/.gitignore

@@ -0,0 +1,6 @@
+# https://dart.dev/guides/libraries/private-files
+# Created by `dart pub`
+.dart_tool/
+*.lock
+!bin
+build/

+ 23 - 0
frameworks/Dart/dart_frog/README.md

@@ -0,0 +1,23 @@
+# Dart Frog Benchmarking Test
+
+### Test Type Implementation Source Code
+
+- [JSON](server.dart)
+- [PLAINTEXT](server.dart)
+
+## Important Libraries
+
+The tests were run with:
+
+- [pkg:dart_frog](https://pub.dev/packages/dart_frog)
+- [Dart](https://dart.dev/)
+
+## Test URLs
+
+### JSON
+
+http://localhost:8080/json
+
+### PLAINTEXT
+
+http://localhost:8080/plaintext

+ 26 - 0
frameworks/Dart/dart_frog/benchmark_config.json

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

+ 16 - 0
frameworks/Dart/dart_frog/dart_frog.dockerfile

@@ -0,0 +1,16 @@
+FROM dart:3.8 AS builder
+
+COPY . /app
+WORKDIR /app
+
+RUN dart pub global activate dart_frog_cli
+RUN dart_frog build
+
+RUN dart compile exe build/bin/server.dart -o build/bin/server
+
+FROM scratch
+COPY --from=builder /runtime/ /
+COPY --from=builder /app/build/bin/server /app/build/bin/
+
+EXPOSE 8080
+CMD ["/app/build/bin/server"]

+ 7 - 0
frameworks/Dart/dart_frog/pubspec.yaml

@@ -0,0 +1,7 @@
+name: dartfrogbenchmark
+description: A benchmark of pkg:dart_frog
+environment:
+  sdk: ^3.8.0
+
+dependencies:
+  dart_frog: ^1.0.0

+ 13 - 0
frameworks/Dart/dart_frog/routes/json.dart

@@ -0,0 +1,13 @@
+import 'dart:io';
+
+import 'package:dart_frog/dart_frog.dart';
+
+Response onRequest(RequestContext context) {
+  return Response.json(
+    body: {'message': 'Hello, World!'},
+    headers: {
+      HttpHeaders.dateHeader: '${HttpDate.format(DateTime.now())}',
+      HttpHeaders.serverHeader: 'dart_frog',
+    },
+  );
+}

+ 13 - 0
frameworks/Dart/dart_frog/routes/plaintext.dart

@@ -0,0 +1,13 @@
+import 'dart:io';
+import 'package:dart_frog/dart_frog.dart';
+
+Response onRequest(RequestContext context) {
+  return Response(
+    body: 'Hello, World!',
+    headers: {
+      HttpHeaders.contentTypeHeader: ContentType.text.mimeType,
+      HttpHeaders.dateHeader: '${HttpDate.format(DateTime.now())}',
+      HttpHeaders.serverHeader: 'dart_frog',
+    },
+  );
+}