Skip to content

0x12th/onetimesecret-1440

Repository files navigation

One time sectet 1440 — share a secret

Build and push image Lints Tests Coverage

pdm-managed code style - Ruff types - Mypy License - MIT

For run prod version

  docker compose -f ./docker-compose/docker-compose.prod.yml up -d

API Reference

Generate a secret code that can be used to get the secret

  POST /generate
Parameter Type Description
secret_message string Required. Sectet message
passphrase string Required. Passphrase
ttl int Optional. Secret lifetime in seconds

Response: secret_key (str)

Get secret

  POST /secrets/{secret_key}
Parameter Type Description
secret_key string Required. Generated secret code that used to get the secret
passphrase string Required. Passphrase

Response: secret_message (str)

Environment Variables

Depending on the app run, copy the values from *-example.env to .env

prod-example.env

for run prod version

dev-example.env

for local dev with db in container

Local development

  docker compose -f ./docker-compose/docker-compose.db.yml up -d --build
  pdm install
  pdm start

Migrations

  • create migration
pdm run alembic revision -m *migration_name* --autogenerate
  • run migrations
pdm run alembic upgrade head
  • downgrade migration
pdm run alembic downgrade -1  # or -2 or base or hash of the migration

Tests

in pytest.ini

  • for github action set: POSTGRES_DSN=postgresql+asyncpg://ots:ots@ots_db/postgres

  • for local dev db in container only set: POSTGRES_DSN=postgresql+asyncpg://onetimesecret:onetimesecret@localhost:65432/onetimesecret

  • run tests
pdm run pytest
  • run test coverage
pdm run pytest --cov=src --cov-fail-under=80