From 82b2bd40751550156add0f67b96a9a4c49faf1b9 Mon Sep 17 00:00:00 2001 From: neri Date: Thu, 9 Jul 2020 22:01:25 +0200 Subject: [PATCH] add readme, extract init-db script --- README.md | 31 +++++++++++++++++++++++++++++++ init-db.sql | 8 ++++++++ screenshot.png | Bin 0 -> 16616 bytes src/main.rs | 20 ++++---------------- 4 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 README.md create mode 100644 init-db.sql create mode 100644 screenshot.png diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b66880 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# datatrash + +A file and text uploading service with configurable time limit + +![Application screenshot](./screenshot.png) + +## compiling + +Compiling is a little strange. +The SQL-statements are checked for correctness at compile-time, unfortunately this means that the +database needs to be running at compile-time too. + +To get set up: + +- Start a postgresql somewhere +- Set its connection url in the `.env` file +- Run the `init-db.sql` script in the database (`cat init-db.sql | psql`) +- Build the project `cargo build --release` + +## running & config + +At runtime the environment variable `DATABASE_URL` must be set (e.g. `postgres://localhost`). +A folder named `files` needs to be created next to the application. + +Other things are not configurable yet. + +- The application listens on port 8000 +- The server url is `http://localhost:8000/` +- The upload limit is 8MiB +- The maximum filename length is 255 +- The uploaded files are stored in the `files` directory diff --git a/init-db.sql b/init-db.sql new file mode 100644 index 0000000..ebbeb9b --- /dev/null +++ b/init-db.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS files ( + id serial, + file_id varchar(255) not null, + file_name varchar(255) not null, + valid_till timestamp not null, + kind varchar(255) not null, + primary key (id) +); diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..f8fdb4527eb6b7ae3e08f6e2f7582b057d1ff074 GIT binary patch literal 16616 zcmeIac{E#l+c)mMd!KSTagNjKgrfs(6{p4;b8gydO=(MMjYkbpL#ZhwBJHW+sG_Qd zP;pQc6(u5sBrR35m?DBm)eu1vLnKHf@9ue?cdg%A@ALlN^{n;0@AJ={wGDgQ`#W6U z>w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ceyv*btq{8>2FIx;YZFjHte6r6$#f6COQgb>*CcW)tnOcPq8=8?o-jH+8kYXSkNE8o9K10&2o?$71y{N9wIm+_t%WxI z?zCi5bg!^hB9SOqQYBTBUKeWpCUn&jfE0(jJm72I|EZOL06drs_u~J_Pkr-D|MmuW zV{l`@gA)Bzz{K`^?Qzcl9)F=)KT^VuG)Z_*f+3updmXjzXsIQfwoadeDFB+8h;H@kh$y%_`Z=#)3LlxubKiLHDDId>hItFFTnrnSL6S`X?79F6Lz(|ZDA1b REiy7Ut~y-7SpN3={{a2%q$dCX literal 0 HcmV?d00001 diff --git a/src/main.rs b/src/main.rs index e1c9f46..c608c8d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -114,21 +114,10 @@ async fn setup_db() -> PgPool { .await .expect("could not create db pool"); - sqlx::query!( - " - CREATE TABLE IF NOT EXISTS files ( - id serial, - file_id varchar(255) not null, - file_name varchar(255) not null, - valid_till timestamp not null, - kind varchar(255) not null, - primary key (id) - ) - " - ) - .execute(&pool) - .await - .expect("could not create table Files"); + sqlx::query_file!("./init-db.sql") + .execute(&pool) + .await + .expect("could not create table Files"); pool } @@ -136,7 +125,6 @@ async fn setup_db() -> PgPool { #[actix_rt::main] async fn main() -> std::io::Result<()> { std::env::set_var("RUST_LOG", "warn,datatrash=info,actix_web=info"); - std::env::set_var("DATABASE_URL", "postgresql://localhost"); env_logger::init(); let pool: PgPool = setup_db().await;