Babies are free
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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.getHumanTranslation(id, userId);
|
||||
if (translation == null) {
|
||||
return Response.json(
|
||||
statusCode: HttpStatus.notFound,
|
||||
body: {'error': 'Translation not found'},
|
||||
);
|
||||
}
|
||||
|
||||
return Response.json(body: translation.toJson());
|
||||
}
|
||||
Reference in New Issue
Block a user