babai/backend/routes/googoo/[id].dart
2025-01-29 17:50:44 -07:00

24 lines
641 B
Dart

import 'dart:io';
import 'package:backend/extensions/request_context.dart';
import 'package:backend/store.dart';
import 'package:dart_frog/dart_frog.dart';
Response onRequest(RequestContext context, String id) {
if (context.request.method != HttpMethod.get) {
return Response(statusCode: HttpStatus.methodNotAllowed);
}
final userId = context.userId;
final translation = MemoryStore.getGoogooTranslation(id, userId);
if (translation == null) {
return Response.json(
statusCode: HttpStatus.notFound,
body: {'error': 'Translation not found'},
);
}
return Response.json(body: translation.toJson());
}