Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust web server: release mode #30

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ed1b93c
Change name of project
noelg-cj Nov 3, 2023
65f4c53
setup template
officiallyaninja Nov 4, 2023
b4377ff
Update .gitignore
officiallyaninja Nov 4, 2023
06d74f3
Create data.db
officiallyaninja Nov 4, 2023
a2eb33a
adding structs for db rows
officiallyaninja Nov 4, 2023
0a60c71
React integrated
noelg-cj Nov 4, 2023
40ed304
Update data.db
officiallyaninja Nov 4, 2023
afca29c
changing from rusqlite to sqlite crate
officiallyaninja Nov 4, 2023
27a6c4d
implementing basic database adding
officiallyaninja Nov 4, 2023
720c0fb
Merge pull request #1 from noelg-cj/rust-web-server
officiallyaninja Nov 4, 2023
a0667a3
Merge pull request #2 from noelg-cj/master
officiallyaninja Nov 4, 2023
f69851e
Update README.md
VB-123 Nov 4, 2023
dae2daa
Merge pull request #1 from VB-123/VB-123-patch-1
VB-123 Nov 4, 2023
d39c217
Merge branch 'noelg-cj:master' into master
VB-123 Nov 4, 2023
240462d
Merge pull request #3 from VB-123/master
VB-123 Nov 4, 2023
93356a1
setup get users
officiallyaninja Nov 5, 2023
411c503
Merge pull request #4 from noelg-cj/rust-web-server
officiallyaninja Nov 5, 2023
3c9003b
get individual user
officiallyaninja Nov 5, 2023
2526013
removed chrono
officiallyaninja Nov 5, 2023
0c7dcb7
added different state for different paths in release and debug mode
officiallyaninja Nov 5, 2023
b61ac5a
added projects with user
officiallyaninja Nov 5, 2023
9f07f0b
adding projects to db
officiallyaninja Nov 5, 2023
ffe4c1b
added get and create tasks
officiallyaninja Nov 5, 2023
d8c641f
more type safe API
officiallyaninja Nov 5, 2023
3d30c1b
Merge pull request #6 from noelg-cj/rust-web-server
officiallyaninja Nov 6, 2023
b79320e
setup subtasks
officiallyaninja Nov 7, 2023
1a82ff1
release mode created tables if necessary now
officiallyaninja Nov 8, 2023
83af7a4
print for where listeneing
officiallyaninja Nov 8, 2023
3b10b21
changed address in release mode
officiallyaninja Nov 8, 2023
0441e33
added deletion
officiallyaninja Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
release mode created tables if necessary now
officiallyaninja committed Nov 8, 2023
commit 1a82ff1ce7aa8218d4cda041070146466531b023
43 changes: 41 additions & 2 deletions web_server/src/main.rs
Original file line number Diff line number Diff line change
@@ -28,7 +28,46 @@ impl AppState {
#[cfg(not(debug_assertions))]
//TODO: make it create db with tables if they don't exist already
fn new() -> Self {
todo!()
Self {
conn: {
let cmd = r#"
CREATE TABLE IF NOT EXISTS "projects" (
"id" INTEGER NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"user_id" INTEGER NOT NULL,
FOREIGN KEY("user_id") REFERENCES "users"("id"),
PRIMARY KEY("id" AUTOINCREMENT)
);
CREATE TABLE IF NOT EXISTS "users" (
"id" INTEGER NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"about" TEXT NOT NULL,
"github_link" TEXT NOT NULL,
"email" TEXT NOT NULL UNIQUE,
PRIMARY KEY("id" AUTOINCREMENT)
);
CREATE TABLE IF NOT EXISTS "tasks" (
"id" INTEGER NOT NULL UNIQUE,
"title" TEXT NOT NULL,
"deadline" TEXT,
"priority" TEXT CHECK("priority" IN ("HIGH", "LOW", "MEDIUM")),
"progress" TEXT CHECK("progress" IN ("NOT_STARTED", "IN_PROGRESS", "COMPLETED")),
"project_id" TEXT NOT NULL,
FOREIGN KEY("project_id") REFERENCES "projects"("id"),
PRIMARY KEY("id" AUTOINCREMENT)
);
CREATE TABLE IF NOT EXISTS "subtasks" (
"id" INTEGER NOT NULL UNIQUE,
"text" TEXT NOT NULL,
"is_completed" INTEGER NOT NULL DEFAULT 0 CHECK("is_completed" IN (0, 1)),
"task_id" INTEGER NOT NULL,
FOREIGN KEY("task_id") REFERENCES "tasks"("id"),
PRIMARY KEY("id" AUTOINCREMENT)
);
"#;
let conn = sqlite::Connection::open_with_full_mutex("../data.db").expect("should open");
conn.execute(cmd).expect("should work"); conn},
}
}
}

@@ -148,7 +187,7 @@ fn get_projects(
};
projects.push(project);
true
})?;
})?; // if conn.iterate failrs, returns Err
Ok(projects)
}