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
feat(api): allow choosing MySQL or PostgreSQL via DB_ENGINE (#151)
* feat(api): allow choosing MySQL or PostgreSQL via DB_ENGINE
Developers can now pick sqlite, mysql, or postgres at startup through a single DB_ENGINE setting, with Docker Compose profiles and local dev containers aligned on the same configuration.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(api): support emoji and punycode domains in analysis tasks (#150)
* fix(api): support emoji and punycode domains in analysis tasks
WebPage validation stores URLs as Unicode, which breaks requests for emoji
domains like xn--3s8h30f.ws. Use AnyHttpUrl for punycode conversion and pass
the encoded URL to the worker queue.
Fixescnumr/EcoIndex#416
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(api): include request error details when URL pre-check fails
Expose SSL, timeout, and DNS errors in the unreachable URL response instead of empty parentheses.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(api): keep DATABASE_URL typed as str for ty compatibility
Use an empty default and resolve it in the model validator so type checkers accept Settings().DATABASE_URL where a str is required.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(api): run alembic migrations from the api project directory
Alembic needs projects/ecoindex_api as the working directory so it can find alembic.ini and load the local .env during init-dev-project.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(api): start dev DB before running alembic migrations
Ensure mysql/postgres containers are up before migration-upgrade and document which DB_HOST to use for local dev versus Docker Compose.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Every services should start normaly, then you can go to:
@@ -62,7 +71,13 @@ Here are the environment variables you can configure in your `.env` file:
62
71
| API |`CORS_ALLOWED_ORIGINS`|`*`| See [MDN web doc](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin)|
63
72
| API |`EXCLUDED_HOSTS`|`["localhost", "127.0.0.1"]`| You can configure a list of hosts that will be excluded from the analysis. |
64
73
| API, Worker |`DAILY_LIMIT_PER_HOST`| 0 | When this variable is set, it won't be possible for a same host to make more request than defined in the same day to avoid overload. If the variable is set, you will get a header `x-remaining-daily-requests: 6` in your response. It is used for the POST methods. If you reach your authorized request quota for the day, the next requests will give you a 429 response. If the variable is set to 0, no limit is set |
65
-
| API, Worker |`DATABASE_URL`|`sqlite+aiosqlite:///./sql_app.db`| If you run your mysql instance on a dedicated server, you can configure it with your credentials. By default, it uses an sqlite database when running in local ||
74
+
| API, Worker |`DB_ENGINE`|`sqlite`| Database backend: `sqlite`, `mysql` or `postgres`. Used to build `DATABASE_URL` when it is not set explicitly. |
75
+
| API, Worker |`DB_HOST`|`localhost`| Database host. Use `db-mysql` or `db-postgres` in Docker Compose. |
76
+
| API, Worker |`DB_PORT`|`3306` / `5432`| Database port. Defaults to the standard port of the selected engine when omitted. |
| API, Worker |`DATABASE_URL`| built from `DB_ENGINE`| Optional explicit SQLAlchemy URL. When set, it overrides `DB_ENGINE` and related variables. Examples: `sqlite+aiosqlite:///db.sqlite3`, `mysql+aiomysql://user:pass@host/db?charset=utf8mb4`, `postgresql+asyncpg://user:pass@host:5432/db`|
66
81
| API, Worker |`SENTRY_DSN`| `` | If you want to use [Sentry](https://sentry.io/) to monitor your application, set this variable with your project DSN. |
67
82
| API, Worker |`SENTRY_ENVIRONMENT`| `` | Optional Sentry environment name (e.g. `production`, `staging`). If not set, defaults to `development` when `DEBUG=True`, otherwise `production`. |
68
83
| API, Worker |`SENTRY_TRACES_SAMPLE_RATE`|`0.0`| Fraction of transactions to send to Sentry for performance monitoring (0.0 to 1.0). Set to `0.1` in production to sample 10% of requests. |
@@ -132,7 +147,13 @@ task api:init-dev-project # Initialize API dev environment (Playwright, .env, mi
132
147
133
148
### Run the API locally
134
149
135
-
Valkey and RustFS are started automatically via Docker. Then run:
150
+
Valkey and RustFS are started automatically via Docker. Set `DB_ENGINE` in `.env` to choose the database:
151
+
152
+
-`sqlite` (default): no database container, file stored locally
153
+
-`mysql`: starts a local MySQL container on port 3306
154
+
-`postgres`: starts a local PostgreSQL container on port 5432
0 commit comments