Skip to content

Commit

Permalink
Basic functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
Enrico Marconi committed Aug 1, 2023
1 parent ad05a85 commit 1ac5f67
Show file tree
Hide file tree
Showing 22 changed files with 1,027 additions and 16 deletions.
81 changes: 81 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ axum = { version = "0.6.19", features = ["tracing", "ws"] }
axum-sessions = "0.5.0"
chrono = { version = "0.4.26", features = ["serde"] }
config = "0.13.3"
futures-util = "0.3.28"
hyper = "0.14.27"
petname = { version = "1.1.3", default-features = false, features = [
"default_dictionary",
Expand All @@ -26,12 +27,15 @@ rand = { version = "0.8.5", features = ["std_rng"] }
serde = { version = "1.0.175", features = ["derive"] }
serde-aux = "4.2.0"
serde_json = "1.0.104"
serde_with = "3.1.0"
sqlx = { version = "0.6.3", default-features = false, features = [
"postgres",
"runtime-tokio-rustls",
"macros",
"migrate",
"offline",
"uuid",
"chrono",
] }
tokio = { version = "1.29.1", features = ["full"] }
tower = "0.4.13"
Expand All @@ -42,6 +46,7 @@ uuid = { version = "1.4.1", features = ["v4", "serde"] }

[dev-dependencies]
once_cell = "1.18.0"
tokio-tungstenite = "0.19.0"
reqwest = { version = "0.11.18", features = [
"json",
"cookies",
Expand Down
3 changes: 2 additions & 1 deletion config/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ db:
username: "emarconi"
password: "supa_password"
name: "todo"

todo_handler:
store_interval: 600
6 changes: 6 additions & 0 deletions migrations/20230731131105_create_todo_lists_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE todo_lists (
id UUID PRIMARY KEY,
name TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
last_updated_at TIMESTAMP WITH TIME ZONE NOT NULL
);
7 changes: 7 additions & 0 deletions migrations/20230731132210_create_todo_tasks_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE todo_tasks (
id UUID PRIMARY KEY,
name TEXT NOT NULL,
assignee UUID NOT NULL,
done BOOLEAN NOT NULL,
list UUID REFERENCES todo_lists(id) NOT NULL
);
111 changes: 111 additions & 0 deletions sqlx-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"db": "PostgreSQL",
"2576e00df7277d4c1bf5ed23bf01eba932db8104da0a89633052ab06524e17a1": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Text"
]
}
},
"query": "\nDELETE FROM user_sessions\nWHERE id = $1\n "
},
"484df88c9bee2c5107f2dca07c1f7a63346431c3eefba163e2204cd71b9b98be": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": []
}
},
"query": "\nDELETE FROM user_sessions\n "
},
"4fb43f8d72e705a5ba8c7c1d2827141b056667065d19daf87869d6dc5cf5f076": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Varchar",
"Varchar"
]
}
},
"query": "\nINSERT INTO user_sessions (id, value)\nVALUES($1, $2)\nON CONFLICT (id)\nDO\n UPDATE SET value = $2\n "
},
"54ad6e2dbc0f52961984df5ebaaae2271a717b044e684eb42c31f4555ff70410": {
"describe": {
"columns": [
{
"name": "id",
"ordinal": 0,
"type_info": "Uuid"
},
{
"name": "name",
"ordinal": 1,
"type_info": "Text"
},
{
"name": "created_at",
"ordinal": 2,
"type_info": "Timestamptz"
},
{
"name": "last_updated_at",
"ordinal": 3,
"type_info": "Timestamptz"
}
],
"nullable": [
false,
false,
false,
false
],
"parameters": {
"Left": [
"Uuid"
]
}
},
"query": "\nSELECT id, name, created_at, last_updated_at \nFROM todo_lists\nWHERE id = $1\n "
},
"67328670c994b74c20fcd4beb70fbea6391852bb54c23caf17256be4e2770cf3": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Uuid",
"Text",
"Timestamptz",
"Timestamptz"
]
}
},
"query": "\nINSERT INTO todo_lists (id, name, created_at, last_updated_at)\n VALUES ($1, $2, $3, $4)\n ON CONFLICT (id) DO\n UPDATE SET name = $2,\n created_at = $3,\n last_updated_at = $4\n "
},
"dd6a583d2d470d784302b97bf81c85c9ef620bd5f72f3b402ea16dd02dffa93a": {
"describe": {
"columns": [
{
"name": "value",
"ordinal": 0,
"type_info": "Varchar"
}
],
"nullable": [
false
],
"parameters": {
"Left": [
"Text"
]
}
},
"query": "\nSELECT value\nFROM user_sessions\nWHERE id = $1\n "
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ pub mod settings;
pub mod startup;
pub mod state;
pub mod telemetry;
pub mod todo;
pub mod user;
3 changes: 2 additions & 1 deletion src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use axum::Router;
use crate::state::AppState;

mod session;
mod todo;

pub fn router() -> Router<AppState> {
Router::new().merge(session::routes())
Router::new().merge(session::routes()).merge(todo::routes())
}
Loading

0 comments on commit 1ac5f67

Please sign in to comment.