You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`ht_api` is the central backend API service for the Headlines Toolkit (HT) project. Built with Dart using the Dart Frog framework, it provides essential APIs to support HT client applications (like the mobile app and web dashboard). It aims for simplicity, maintainability, and scalability, currently offering APIs for data access and user settings management.
10
-
11
-
## API Endpoints:
12
-
13
-
### Authentication (`/api/v1/auth`)
14
-
15
-
These endpoints handle user authentication flows.
16
-
17
-
**Standard Response Structure:** Uses the same `SuccessApiResponse` and error structure as the Data API. Authentication success responses typically use `SuccessApiResponse<AuthSuccessResponse>` (containing User and token) or `SuccessApiResponse<User>`.
***Error Response:**`401 Unauthorized` (if not authenticated), `400 Bad Request` (if not anonymous or invalid email), `409 Conflict` (if email is already in use or linking is pending).
50
-
***Example:**`POST /api/v1/auth/link-email` with body `{"email": "[email protected]"}` and `Authorization: Bearer <anonymous_token>` header.
51
-
52
-
5.**Complete Account Linking (Anonymous User)**
53
-
***Method:**`POST`
54
-
***Path:**`/api/v1/auth/verify-link-email`
55
-
***Authentication:** Required (Bearer Token of the *anonymous* user who initiated the link).
***Success Response:**`200 OK` with `SuccessApiResponse<AuthSuccessResponse>` containing the updated (now permanent) `User` object and a **new** authentication `token`.
58
-
***Error Response:**`401 Unauthorized` (if not authenticated), `400 Bad Request` (if not anonymous or invalid code), `400 Bad Request` via `InvalidInputException` (if code is incorrect/expired).
59
-
***Example:**`POST /api/v1/auth/verify-link-email` with body `{"code": "654321"}` and `Authorization: Bearer <anonymous_token>` header.
60
-
61
-
6.**Get Current User Details**
62
-
***Method:**`GET`
63
-
***Path:**`/api/v1/auth/me`
64
-
***Authentication:** Required (Bearer Token).
65
-
***Success Response:**`200 OK` with `SuccessApiResponse<User>` containing the details of the authenticated user.
66
-
***Error Response:**`401 Unauthorized`.
67
-
***Example:**`GET /api/v1/auth/me` with `Authorization: Bearer <token>` header.
68
-
69
-
7.**Sign Out**
70
-
***Method:**`POST`
71
-
***Path:**`/api/v1/auth/sign-out`
72
-
***Authentication:** Required (Bearer Token).
73
-
***Request Body:** None.
74
-
***Success Response:**`204 No Content` (Indicates successful server-side action, if any). Client is responsible for clearing local token.
75
-
***Error Response:**`401 Unauthorized`.
76
-
***Example:**`POST /api/v1/auth/sign-out` with `Authorization: Bearer <token>` header.
77
-
78
-
8.**Delete Account**
79
-
***Method:**`DELETE`
80
-
***Path:**`/api/v1/auth/delete-account`
81
-
***Authentication:** Required (Bearer Token).
82
-
***Request Body:** None.
83
-
***Success Response:**`204 No Content` (Indicates successful deletion).
84
-
***Error Response:**`401 Unauthorized` (if not authenticated), `404 Not Found` (if the user was already deleted), or other standard errors via the error handler middleware.
85
-
***Example:**`DELETE /api/v1/auth/delete-account` with `Authorization: Bearer <token>` header.
86
-
87
-
### Data (`/api/v1/data`)
88
-
89
-
**Authentication required for all operations.**
90
-
91
-
This endpoint serves as the single entry point for accessing different data models. The specific model is determined by the `model` query parameter.
@@ -220,16 +74,21 @@ These endpoints manage application settings for an authenticated user. The `{use
220
74
```bash
221
75
dart_frog dev
222
76
```
223
-
The API will typically be available at `http://localhost:8080`. Fixture data from `lib/src/fixtures/` will be loaded into the in-memory repositories on startup.
77
+
The API will typically be available at `http://localhost:8080`. Fixture data
78
+
from `lib/src/fixtures/` will be loaded into the in-memory repositories on
79
+
startup.
224
80
225
-
## Testing
81
+
## ✅ Testing
226
82
227
-
* Run tests and check coverage (aim for >= 90%):
228
-
```bash
229
-
# Ensure very_good_cli is activated: dart pub global activate very_good_cli
230
-
very_good test --min-coverage 90
231
-
```
232
-
233
-
## License
83
+
Ensure the API is robust and meets quality standards by running the test suite:
84
+
85
+
```bash
86
+
# Ensure very_good_cli is activated: dart pub global activate very_good_cli
87
+
very_good test --min-coverage 90
88
+
```
89
+
90
+
Aim for a minimum of 90% line coverage.
91
+
92
+
## 📄 License
234
93
235
94
This package is licensed under the [PolyForm Free Trial](LICENSE). Please review the terms before use.
0 commit comments