Compare commits

..

3 Commits

Author SHA1 Message Date
9dfd012dea docs(README): open links in new tabs
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 13m44s
2025-11-17 10:16:28 +01:00
399f30157f chore: add Sonar analysis
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 12m32s
2025-11-16 02:02:58 +01:00
0b60e67e19 feat: send confirmation email to sender
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 8m13s
When users submit a contact form, they now receive a confirmation
email acknowlledging receipt of their message. The backend also
continues to send a notification email to the configured recipient.

If the backend fails to send the acknowledgement email to the sender,
it will assume the email is not valid and will therefore not transmit
the contact request to the configured recipient.

Changes:
- Refactor `send_email()` to `send_emails()` that sends two emails:
  - Confirmation email from the submitter
  - Notification email to the configured recipient
- Add `From<T>` implementations of various errors for new error type
  `ContactError`.
- Errors now return a translation identifier for the frontend.
2025-11-15 23:43:44 +01:00
10 changed files with 46 additions and 50 deletions

View File

@@ -84,7 +84,7 @@ Cachix is a Nix binary cache that dramatically speeds up builds by caching build
Configure these in the workflow's `env` section or as repository variables:
| Variable | Description | Default Value | Example |
|--------------------|------------------------------------------------|---------------|--------------------|
|--------------------+------------------------------------------------+---------------+--------------------|
| `CACHIX_NAME` | Name of the Cachix cache to use | `devenv` | `phundrak-dot-com` |
| `CACHIX_SKIP_PUSH` | Whether to skip pushing artifacts to the cache | `true` | `false` |

40
Cargo.lock generated
View File

@@ -134,26 +134,6 @@ dependencies = [
"fs_extra",
]
[[package]]
name = "bakit"
version = "0.1.0"
dependencies = [
"chrono",
"config",
"dotenvy",
"governor",
"lettre",
"poem",
"poem-openapi",
"serde",
"serde_json",
"thiserror",
"tokio",
"tracing",
"tracing-subscriber",
"validator",
]
[[package]]
name = "base64"
version = "0.21.7"
@@ -1593,6 +1573,26 @@ dependencies = [
"sha2",
]
[[package]]
name = "phundrak-dot-com-backend"
version = "0.1.0"
dependencies = [
"chrono",
"config",
"dotenvy",
"governor",
"lettre",
"poem",
"poem-openapi",
"serde",
"serde_json",
"thiserror",
"tokio",
"tracing",
"tracing-subscriber",
"validator",
]
[[package]]
name = "pin-project"
version = "0.4.30"

View File

@@ -1,5 +1,5 @@
[package]
name = "bakit"
name = "phundrak-dot-com-backend"
version = "0.1.0"
edition = "2024"
publish = false
@@ -11,7 +11,7 @@ path = "src/lib.rs"
[[bin]]
path = "src/main.rs"
name = "bakit"
name = "phundrak-dot-com-backend"
[dependencies]
chrono = { version = "0.4.42", features = ["serde"] }

View File

@@ -3,20 +3,14 @@ include_toc: true
gitea: none
---
<h1 align="center">Bakit</h1>
<div align="center">
<strong>
A backend for my personal website
</strong>
</div>
<br/>
# phundrak.com Backend
<div align="center">
<a href="https://sonar.phundrak.com/dashboard?id=bakit" target="_blank">
<img src="https://sonar.phundrak.com/api/project_badges/measure?project=bakit&metric=coverage&token=sqb_bda24bf36825576d6c6b76048044e103339c3c5f" alt="Sonar Coverage" />
<a href="https://sonar.phundrak.com/dashboard?id=phundrak-backend" target="_blank">
<img src="https://sonar.phundrak.com/api/project_badges/measure?project=phundrak-backend&metric=coverage&token=sqb_bda24bf36825576d6c6b76048044e103339c3c5f" alt="Sonar Coverage" />
</a>
<a href="https://sonar.phundrak.com/dashboard?id=bakit" target="_blank">
<img src="https://sonar.phundrak.com/api/project_badges/measure?project=bakit&metric=alert_status&token=sqb_bda24bf36825576d6c6b76048044e103339c3c5f" alt="Sonar Quality Gate Status" />
<a href="https://sonar.phundrak.com/dashboard?id=phundrak-backend" target="_blank">
<img src="https://sonar.phundrak.com/api/project_badges/measure?project=phundrak-backend&metric=alert_status&token=sqb_bda24bf36825576d6c6b76048044e103339c3c5f" alt="Sonar Quality Gate Status" />
</a>
<a href="#license">
<img src="https://img.shields.io/badge/License-AGPL--3.0--only-blue" alt="License" />
@@ -26,6 +20,8 @@ gitea: none
</a>
</div>
The backend for [phundrak.com](https://phundrak.com), built with Rust and the [Poem](https://github.com/poem-web/poem) web framework.
## Features
- **RESTful API** with automatic OpenAPI/Swagger documentation
@@ -141,14 +137,14 @@ For optimized production builds:
cargo build --release
```
The compiled binary will be at `target/release/bakit`.
The compiled binary will be at `target/release/backend`.
**With Nix:**
Build the backend binary:
```bash
nix build .#backend
# Binary available at: ./result/bin/bakit
# Binary available at: ./result/bin/backend
```
Build Docker images:
@@ -161,7 +157,7 @@ nix build .#backendDockerLatest
# Load into Docker
docker load < result
# Image will be available as: localhost/phundrak/bakit:latest
# Image will be available as: localhost/phundrak/backend-rust:latest
```
The Nix build ensures reproducible builds with all dependencies pinned.
@@ -336,7 +332,7 @@ Docker images are automatically built and published via GitHub Actions to the co
Pull and run the latest image:
```bash
# Pull from Phundrak Labs (labs.phundrak.com)
docker pull labs.phundrak.com/phundrak/bakit:latest
docker pull labs.phundrak.com/phundrak/phundrak-dot-com-backend:latest
# Run the container
docker run -d \
@@ -349,7 +345,7 @@ docker run -d \
-e APP__EMAIL__PASSWORD=your_password \
-e APP__EMAIL__FROM="Contact Form <noreply@example.com>" \
-e APP__EMAIL__RECIPIENT="Admin <admin@example.com>" \
labs.phundrak.com/phundrak/bakit:latest
labs.phundrak.com/phundrak/phundrak-dot-com-backend:latest
```
### Available Image Tags
@@ -367,7 +363,7 @@ Build with Nix (recommended for reproducibility):
```bash
nix build .#backendDockerLatest
docker load < result
docker run -p 3100:3100 localhost/phundrak/bakit:latest
docker run -p 3100:3100 localhost/phundrak/backend-rust:latest
```
Build with Docker directly:
@@ -383,7 +379,7 @@ version: '3.8'
services:
backend:
image: labs.phundrak.com/phundrak/bakit:latest
image: labs.phundrak.com/phundrak/phundrak-dot-com-backend:latest
ports:
- "3100:3100"
environment:
@@ -435,7 +431,7 @@ To use the published images, authenticate with the registry:
echo $GITHUB_TOKEN | docker login labs.phundrak.com -u USERNAME --password-stdin
# Pull the image
docker pull labs.phundrak.com/phundrak/bakit:latest
docker pull labs.phundrak.com/phundrak/phundrak-dot-com-backend:latest
```
### Required Secrets

View File

@@ -5,7 +5,7 @@ application:
protocol: http
host: 127.0.0.1
base_url: http://127.0.0.1:3100
name: "bakit-dev"
name: "com.phundrak.backend.dev"
email:
host: localhost

View File

@@ -2,7 +2,7 @@ debug: false
frontend_url: ""
application:
name: "bakit-prod"
name: "com.phundrak.backend.prod"
protocol: https
host: 0.0.0.0
base_url: ""

View File

@@ -1 +1 @@
sonar.projectKey=bakit
sonar.projectKey=phundrak-backend

View File

@@ -3,5 +3,5 @@
#[cfg(not(tarpaulin_include))]
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
bakit::run(None).await
phundrak_dot_com_backend::run(None).await
}

View File

@@ -268,7 +268,7 @@ mod tests {
#[test]
fn from_validation_errors_with_name_error() {
use validator::Validate;
use validator::{Validate, ValidationError};
#[derive(Validate)]
struct TestStruct {

View File

@@ -933,7 +933,7 @@ mod tests {
assert!(result.is_err());
match result.unwrap_err() {
ContactError::CouldNotParseSettingsEmail(_) => (),
e => panic!("Expected CouldNotParseSettingsEmail, got {e:?}"),
e => panic!("Expected CouldNotParseSettingsEmail, got {:?}", e),
}
}
@@ -964,7 +964,7 @@ mod tests {
assert!(result.is_err());
match result.unwrap_err() {
ContactError::CouldNotParseRequestEmailAddress(_) => (),
e => panic!("Expected CouldNotParseRequestEmailAddress, got {e:?}"),
e => panic!("Expected CouldNotParseRequestEmailAddress, got {:?}", e),
}
}
@@ -996,7 +996,7 @@ mod tests {
assert!(result.is_err());
match result.unwrap_err() {
ContactError::CouldNotSendEmail(_) => (),
e => panic!("Expected CouldNotSendEmail, got {e:?}"),
e => panic!("Expected CouldNotSendEmail, got {:?}", e),
}
}
}