Skip to content

Feature document database migration #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jul 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
49d1e91
feat(auth): create ownership check middleware
fulleni Jul 11, 2025
ea709e9
feat(auth): apply ownership check middleware to item routes
fulleni Jul 11, 2025
cc9d32f
refactor(api): adapt GET /data to use native document query
fulleni Jul 11, 2025
34a0029
refactor(api): adapt GET /data to use native document query
fulleni Jul 11, 2025
c065be4
feat(db): replace postgres seeding service with mongodb
fulleni Jul 11, 2025
fe51a1e
feat(db): replace postgres seeding service with mongodb
fulleni Jul 11, 2025
1bca9ab
refactor(deps): remove postgres dependencies
fulleni Jul 11, 2025
bfb3e5f
feat(db): migrate dependency injection to mongodb
fulleni Jul 11, 2025
bf6f59d
docs: update readme for mongodb migration
fulleni Jul 11, 2025
c6877bc
refactor(auth): use readAll with filter in AuthService
fulleni Jul 11, 2025
38853ea
docs: update .env.example for mongodb connection string
fulleni Jul 11, 2025
b07d6d2
fix(config): make .env file loading robust
fulleni Jul 11, 2025
7b24b53
/// issues where the execution context's working directory is not the
fulleni Jul 11, 2025
20a92d2
fix(config): correct directory traversal in .env search
fulleni Jul 11, 2025
96912c2
feat(config): enhance .env loading logs
fulleni Jul 11, 2025
e7d0d8d
fix(config): prevent state corruption on failed dependency init
fulleni Jul 11, 2025
d1ac01a
fix(config): make dependency init robust against all throwables
fulleni Jul 11, 2025
6e84bcf
chore
fulleni Jul 11, 2025
4ce3cc5
fix(api): make database seeding idempotent and preserve IDs
fulleni Jul 12, 2025
5207475
fix(api): ensure all user data is deleted on account deletion
fulleni Jul 12, 2025
dbae817
refactor(api): use repository count method for dashboard summary
fulleni Jul 12, 2025
c49d2c4
fix(api): improve error handling for invalid JSON body
fulleni Jul 12, 2025
b2b4363
fix(api): correct admin data scoping in generic data handlers
fulleni Jul 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This is an example environment file.
# Copy this file to .env and fill in your actual configuration values.
# The .env file is ignored by Git and should NOT be committed.

# DATABASE_URL="mongodb://user:password@localhost:27017/ht_api_db"
DATABASE_URL="mongodb://localhost:27017/ht_api_db"
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Copy this file to .env and fill in your actual configuration values.
# The .env file is ignored by Git and should NOT be committed.

DATABASE_URL="postgres://user:password@localhost:5432/db_name"
DATABASE_URL="mongodb://user:password@localhost:27017/ht_api_db"
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ management dashboard](https://github.com/headlines-toolkit/ht-dashboard).
behavior—including ad frequency, feature flags, and maintenance status—without
requiring a client-side update.

* 💾 **Robust Data Management:** Securely manage core news data (headlines,
topics, sources) through a well-structured API that supports flexible
querying and sorting for dynamic content presentation.

* 📊 **Dynamic Dashboard Summary:** Access real-time, aggregated metrics on
key data points like total headlines, topics, and sources, providing
an at-a-glance overview for administrative dashboards.
Expand Down Expand Up @@ -75,7 +71,7 @@ for more details.

1. **Prerequisites:**
* Dart SDK (`>=3.0.0`)
* PostgreSQL (`>=14.0` recommended)
* MongoDB (`>=5.0` recommended)
* Dart Frog CLI (`dart pub global activate dart_frog_cli`)

2. **Configuration:**
Expand All @@ -85,7 +81,7 @@ for more details.
Create a `.env` file in the root of the project or export the variable in
your shell:
```
DATABASE_URL="postgres://user:password@localhost:5432/ht_api_db"
DATABASE_URL="mongodb://user:password@localhost:27017/ht_api_db"
```

3. **Clone the repository:**
Expand All @@ -101,11 +97,10 @@ for more details.
```bash
dart_frog dev
```
The API will typically be available at `http://localhost:8080`. On the
first startup, the server will connect to your PostgreSQL database, create the
necessary tables, and seed them with initial fixture data. This process is
non-destructive; it uses `CREATE TABLE IF NOT EXISTS` and `INSERT ... ON
CONFLICT DO NOTHING` to avoid overwriting existing tables or data.
The API will typically be available at `http://localhost:8080`. On startup,
the server will connect to your MongoDB database and seed it with initial
fixture data. This seeding process is idempotent (using `upsert`
operations), so it can be run multiple times without creating duplicates.


**Note on Web Client Integration (CORS):** To allow web applications (like
Expand Down
Loading
Loading