Skip to content

Commit f389fc8

Browse files
committed
try terraform
1 parent 7c1a0b7 commit f389fc8

File tree

11 files changed

+51
-5
lines changed

11 files changed

+51
-5
lines changed

backend/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

frontend/src/routes/api/v1/auth/requestLink/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const POST: RequestHandler = async (event) => {
5656
.bind(token, email, expiresAt)
5757
.run();
5858
} catch (e) {
59-
console.error("D1 insert failed:", e);
59+
//console.error("D1 insert failed:", e);
6060
if (prod) return httpError("INTERNAL", "database error", 500);
6161
}
6262

frontend/src/routes/api/v1/auth/verify/+server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const handleVerify: RequestHandler = async (event) => {
4444
}
4545
email = row.email.toLowerCase();
4646
} catch (e) {
47-
console.error("D1 select failed:", e);
47+
//console.error("D1 select failed:", e);
4848
if (prod) return httpError("INTERNAL", "database error", 500);
4949
}
5050

@@ -59,7 +59,7 @@ const handleVerify: RequestHandler = async (event) => {
5959
env.DB.prepare("DELETE FROM magic_tokens WHERE token=?1").bind(token),
6060
]);
6161
} catch (e) {
62-
console.error("D1 upsert/delete failed:", e);
62+
//console.error("D1 upsert/delete failed:", e);
6363
if (prod) return httpError("INTERNAL", "database error", 500);
6464
}
6565

infra/terraform/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

infra/terraform/dev.tfvars

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
account_id = "cf_account_id_dev"
2+
zone_id = "cf_zone_id_dev"
3+
project_name = "unitn-oj-dev"
4+
queue_name = "unitn-oj-submissions-dev"

infra/terraform/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "cloudflare_pages_project" "frontend" {
2+
account_id = var.account_id
3+
name = "${var.project_name}-pages"
4+
production_branch = "main"
5+
}
6+
7+
resource "cloudflare_d1_database" "db" {
8+
account_id = var.account_id
9+
name = "${var.project_name}-d1"
10+
}
11+
12+
resource "cloudflare_queue" "submissions" {
13+
account_id = var.account_id
14+
queue_name = var.queue_name
15+
}

infra/terraform/outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "pages_project_name" { value = cloudflare_pages_project.frontend.name }
2+
output "d1_db_id" { value = cloudflare_d1_database.db.id }
3+
output "queue_name" { value = cloudflare_queue.submissions.queue_name }

infra/terraform/prod.tfvars

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
account_id = "cf_account_id_prod"
2+
zone_id = "cf_zone_id_prod"
3+
project_name = "unitn-oj"
4+
queue_name = "unitn-oj-submissions"

infra/terraform/providers.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "cloudflare" {
2+
api_token = var.cf_api_token
3+
}

infra/terraform/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
variable "cf_api_token" {
2+
type = string
3+
description = "Cloudflare API token with required scopes"
4+
sensitive = true
5+
}
6+
variable "account_id" { type = string }
7+
variable "zone_id" { type = string }
8+
9+
variable "project_name" { type = string }
10+
variable "queue_name" { type = string }

0 commit comments

Comments
 (0)