adds server to serve the static files, fixes db tables
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,4 +5,5 @@ node_modules
|
|||||||
fontawesome
|
fontawesome
|
||||||
|
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
**/*.sqlite3
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ version = "0.1.0"
|
|||||||
authors = ["Artus <artus@landoftheunicorn.ovh>"]
|
authors = ["Artus <artus@landoftheunicorn.ovh>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
actix-web = "0.7"
|
||||||
|
lootalot-db = { version = "0.1", path = "./lootalot_db" }
|
||||||
|
dotenv = "*"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"lootalot_db"
|
"lootalot_db"
|
||||||
|
|||||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
CREATE TABLE items (
|
CREATE TABLE items (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
name VARCHAR NOT NULL,
|
name VARCHAR NOT NULL,
|
||||||
base_price INTEGER NOT NULL
|
base_price INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
CREATE TABLE players (
|
CREATE TABLE players (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
name VARCHAR NOT NULL,
|
name VARCHAR NOT NULL,
|
||||||
debt INTEGER DEFAULT 0, -- debt to the group in copper pieces
|
debt INTEGER DEFAULT 0 NOT NULL, -- debt to the group in copper pieces
|
||||||
cp INTEGER DEFAULT 0,
|
cp INTEGER DEFAULT 0 NOT NULL,
|
||||||
sp INTEGER DEFAULT 0,
|
sp INTEGER DEFAULT 0 NOT NULL,
|
||||||
gp INTEGER DEFAULT 0,
|
gp INTEGER DEFAULT 0 NOT NULL,
|
||||||
pp INTEGER DEFAULT 0
|
pp INTEGER DEFAULT 0 NOT NULL
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
CREATE TABLE looted (
|
CREATE TABLE looted (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY NOT NULL,
|
||||||
player_id INTEGER NOT NULL,
|
player_id INTEGER NOT NULL,
|
||||||
item_id INTEGER NOT NULL,
|
item_id INTEGER NOT NULL,
|
||||||
acquired_date DATE DEFAULT NOW,
|
acquired_date DATE NOT NULL,
|
||||||
FOREIGN KEY (player_id) REFERENCES players(id),
|
FOREIGN KEY (player_id) REFERENCES players(id),
|
||||||
FOREIGN KEY (item_id) REFERENCES items(id)
|
FOREIGN KEY (item_id) REFERENCES items(id)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ pub fn list_players() -> Vec<models::Player> {
|
|||||||
players
|
players
|
||||||
.load::<models::Player>(&conn)
|
.load::<models::Player>(&conn)
|
||||||
.expect("Error loading players")
|
.expect("Error loading players")
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
table! {
|
table! {
|
||||||
items (id) {
|
items (id) {
|
||||||
id -> Nullable<Integer>,
|
id -> Integer,
|
||||||
name -> Text,
|
name -> Text,
|
||||||
base_price -> Integer,
|
base_price -> Integer,
|
||||||
}
|
}
|
||||||
@@ -8,22 +8,22 @@ table! {
|
|||||||
|
|
||||||
table! {
|
table! {
|
||||||
looted (id) {
|
looted (id) {
|
||||||
id -> Nullable<Integer>,
|
id -> Integer,
|
||||||
player_id -> Integer,
|
player_id -> Integer,
|
||||||
item_id -> Integer,
|
item_id -> Integer,
|
||||||
acquired_date -> Nullable<Date>,
|
acquired_date -> Date,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
players (id) {
|
players (id) {
|
||||||
id -> Nullable<Integer>,
|
id -> Integer,
|
||||||
name -> Text,
|
name -> Text,
|
||||||
debt -> Nullable<Integer>,
|
debt -> Integer,
|
||||||
cp -> Nullable<Integer>,
|
cp -> Integer,
|
||||||
sp -> Nullable<Integer>,
|
sp -> Integer,
|
||||||
gp -> Nullable<Integer>,
|
gp -> Integer,
|
||||||
pp -> Nullable<Integer>,
|
pp -> Integer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
20
src/main.rs
20
src/main.rs
@@ -1,5 +1,25 @@
|
|||||||
extern crate lootalot_db;
|
extern crate lootalot_db;
|
||||||
|
extern crate actix_web;
|
||||||
|
extern crate dotenv;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use std::cell::RefCell;
|
||||||
|
use std::rc::Rc;
|
||||||
|
use actix_web::{server, App, Result, HttpRequest, fs };
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
||||||
|
dotenv::dotenv().ok();
|
||||||
|
|
||||||
|
let www_root: String = env::var("WWW_ROOT").expect("WWW_ROOT must be set");
|
||||||
|
println!("serving files from: {}", &www_root);
|
||||||
|
server::new(move || {
|
||||||
|
App::new()
|
||||||
|
.handler("/", fs::StaticFiles::new(www_root.clone()).unwrap().index_file("index.html"))
|
||||||
|
})
|
||||||
|
.bind("127.0.0.1:8088")
|
||||||
|
.unwrap()
|
||||||
|
.run();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user