From 95057b1db5f4c8d911c515168cdbe168cd5ccc13 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 3 Jun 2024 21:06:36 -0700 Subject: [PATCH] review feedback --- pkgs/dart_services/lib/src/common_server.dart | 14 +++++++------- pkgs/dartpad_shared/lib/services.dart | 7 +------ pkgs/dartpad_shared/pubspec.yaml | 1 + 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/pkgs/dart_services/lib/src/common_server.dart b/pkgs/dart_services/lib/src/common_server.dart index 5111aa2dc..8e823e467 100644 --- a/pkgs/dart_services/lib/src/common_server.dart +++ b/pkgs/dart_services/lib/src/common_server.dart @@ -209,13 +209,6 @@ class CommonServerApi { Future gemini(Request request, String apiVersion) async { if (apiVersion != api3) return unhandledVersion(apiVersion); - // Read the api key from env variables (populated on the server). - final apiKey = googleApiKey; - if (apiKey == null) { - return Response.internalServerError( - body: 'gemini key not configured on server'); - } - // Only allow the call from known clients / endpoints. const firebaseHostAddress = '199.36.158.100'; const localHostAddress = '127.0.0.1'; @@ -227,6 +220,13 @@ class CommonServerApi { body: 'gemini calls only allowed from the DartPad frontend'); } + // Read the api key from env variables (populated on the server). + final apiKey = googleApiKey; + if (apiKey == null) { + return Response.internalServerError( + body: 'gemini key not configured on server'); + } + final sourceRequest = api.SourceRequest.fromJson(await request.readAsJson()); diff --git a/pkgs/dartpad_shared/lib/services.dart b/pkgs/dartpad_shared/lib/services.dart index e9bf37b14..71c024a50 100644 --- a/pkgs/dartpad_shared/lib/services.dart +++ b/pkgs/dartpad_shared/lib/services.dart @@ -5,6 +5,7 @@ import 'dart:convert'; import 'package:http/http.dart'; +import 'package:meta/meta.dart'; import 'model.dart'; @@ -97,9 +98,3 @@ class ApiRequestError implements Exception { @override String toString() => '$message: $body'; } - -class _Experimental { - const _Experimental(); -} - -const Object experimental = _Experimental(); diff --git a/pkgs/dartpad_shared/pubspec.yaml b/pkgs/dartpad_shared/pubspec.yaml index 9bed6f1a6..b7668d164 100644 --- a/pkgs/dartpad_shared/pubspec.yaml +++ b/pkgs/dartpad_shared/pubspec.yaml @@ -8,6 +8,7 @@ environment: dependencies: http: ^1.1.0 json_annotation: ^4.9.0 + meta: ^1.14.0 dev_dependencies: build_runner: ^2.4.5