Skip to content

Commit 39bc43f

Browse files
committed
feat(api): add response metadata to verify-link-email endpoint
Standardizes the success response for the verify-link-email endpoint by including the `ResponseMetadata` object, which contains the `requestId` and a timestamp. This ensures that all successful authentication responses that return a body are structured consistently, improving API uniformity.
1 parent fe9055d commit 39bc43f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

routes/api/v1/auth/verify-link-email.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import 'dart:io';
22

33
import 'package:dart_frog/dart_frog.dart';
44
import 'package:ht_api/src/services/auth_service.dart';
5-
import 'package:ht_shared/ht_shared.dart'; // For User, AuthSuccessResponse, exceptions
5+
import 'package:ht_shared/ht_shared.dart';
6+
7+
import '../../../_middleware.dart';
68

79
/// Handles POST requests to `/api/v1/auth/verify-link-email`.
810
///
@@ -88,10 +90,16 @@ Future<Response> onRequest(RequestContext context) async {
8890
token: result.token,
8991
);
9092

93+
// Create metadata, including the requestId from the context.
94+
final metadata = ResponseMetadata(
95+
requestId: context.read<RequestId>().id,
96+
timestamp: DateTime.now().toUtc(),
97+
);
98+
9199
// Wrap the payload in the standard SuccessApiResponse
92100
final responsePayload = SuccessApiResponse<AuthSuccessResponse>(
93101
data: authPayload,
94-
// metadata: ResponseMetadata(timestamp: DateTime.now().toUtc()),
102+
metadata: metadata,
95103
);
96104

97105
// Return 200 OK with the standardized, serialized response

0 commit comments

Comments
 (0)