From 3a9a9fb2cad98012d04d689e685bccf1f1751ebf Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sun, 20 Aug 2023 14:30:11 +0200 Subject: [PATCH] feat(docker): dockerized project --- .dockerignore | 3 + ...79320ad9dd95c29c0683e77862545bef11faa.json | 14 ++++ ...3aa937cf76286e98f7e66c342fb87a3896265.json | 76 +++++++++++++++++++ ...3ba8437c308bf6125cad5f483efadd02722cb.json | 34 +++++++++ ...27b2063cee27f9bad1b06cceaa3b95e93664c.json | 16 ++++ ...7446a300e19a13e75cea465ed5bafa5169416.json | 14 ++++ ...50408249ae7f03356121968abf1039407ec3e.json | 12 +++ ...ed021c2436e57112259a8b0e208e4aa7628ae.json | 12 +++ ...e40b0c863578fbafd7096613cde631f4ed7f4.json | 14 ++++ ...1905d159c3bbfe0c8e78876a8cd2b952e28b5.json | 76 +++++++++++++++++++ ...3b046a70aefd4ac2dcbf3268e34c9576e903e.json | 76 +++++++++++++++++++ ...9b658adafa9c58b79e6dd867f6e4f62fbd144.json | 18 +++++ ...7daae3b3c34aa59093878a7d20a2598269a34.json | 34 +++++++++ ...d0e3b4494401e59650c06b6332557d51e5452.json | 14 ++++ ...1e8a8466ed37c2c22e5d40d9aeb7da0f7ce59.json | 34 +++++++++ ...a3f9adcfd54c3fce5a7a35c87aba3937e794c.json | 14 ++++ ...0fb0d56d2e02f4aba71e090ac0451b50cf56b.json | 16 ++++ ...31bdd1083c402c2409388f522767bbcdc2806.json | 12 +++ ...e9fc3ea098706d958721495dafbe40628251a.json | 34 +++++++++ ...117953f781bd3f3f2afe6fd0b266da541df8c.json | 12 +++ Dockerfile | 31 ++++++++ docs/README.md | 2 + src/api/account/calls.rs | 2 +- src/api/account/data.rs | 5 ++ src/api/mod.rs | 2 +- 25 files changed, 575 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 .sqlx/query-0d2502c392758afae3b433e952779320ad9dd95c29c0683e77862545bef11faa.json create mode 100644 .sqlx/query-0e894c84befe397687d4820ea313aa937cf76286e98f7e66c342fb87a3896265.json create mode 100644 .sqlx/query-1a96696cf2ad271f7001e89ec733ba8437c308bf6125cad5f483efadd02722cb.json create mode 100644 .sqlx/query-371fb1eff8cebe11d8527bda9ac27b2063cee27f9bad1b06cceaa3b95e93664c.json create mode 100644 .sqlx/query-3b0db22c46875b6cc12eb1710ef7446a300e19a13e75cea465ed5bafa5169416.json create mode 100644 .sqlx/query-5a65288ceaee7044d547a04600d50408249ae7f03356121968abf1039407ec3e.json create mode 100644 .sqlx/query-699dbb92baf5954e5457dbd2dfded021c2436e57112259a8b0e208e4aa7628ae.json create mode 100644 .sqlx/query-6c470deaeaf19e799df3889436de40b0c863578fbafd7096613cde631f4ed7f4.json create mode 100644 .sqlx/query-7009cdfba0b6c8d7c8ed9d49bf91905d159c3bbfe0c8e78876a8cd2b952e28b5.json create mode 100644 .sqlx/query-71b834dfe4384a536257b888e293b046a70aefd4ac2dcbf3268e34c9576e903e.json create mode 100644 .sqlx/query-8b37c356c1df9961b47359a56f69b658adafa9c58b79e6dd867f6e4f62fbd144.json create mode 100644 .sqlx/query-994b743e8d80be58b6b41f4fd0f7daae3b3c34aa59093878a7d20a2598269a34.json create mode 100644 .sqlx/query-af7d6e7978039e8493371a2f520d0e3b4494401e59650c06b6332557d51e5452.json create mode 100644 .sqlx/query-bae0e81b05f7f2118beac49a2691e8a8466ed37c2c22e5d40d9aeb7da0f7ce59.json create mode 100644 .sqlx/query-d703f0f7593a46686b6b2d44bdaa3f9adcfd54c3fce5a7a35c87aba3937e794c.json create mode 100644 .sqlx/query-d71ba18cd27ffc0b3ec7d6fb3e00fb0d56d2e02f4aba71e090ac0451b50cf56b.json create mode 100644 .sqlx/query-d7aa893f2cd4154c72883bf50a031bdd1083c402c2409388f522767bbcdc2806.json create mode 100644 .sqlx/query-d89d2c78b57727c5fcdc45dcb7ae9fc3ea098706d958721495dafbe40628251a.json create mode 100644 .sqlx/query-f77dc2bcb3826a98bebee9bbcb3117953f781bd3f3f2afe6fd0b266da541df8c.json create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f058998 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +docs +target +README.md diff --git a/.sqlx/query-0d2502c392758afae3b433e952779320ad9dd95c29c0683e77862545bef11faa.json b/.sqlx/query-0d2502c392758afae3b433e952779320ad9dd95c29c0683e77862545bef11faa.json new file mode 100644 index 0000000..bc374f9 --- /dev/null +++ b/.sqlx/query-0d2502c392758afae3b433e952779320ad9dd95c29c0683e77862545bef11faa.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE Accounts SET verified=true WHERE id = $1;", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "0d2502c392758afae3b433e952779320ad9dd95c29c0683e77862545bef11faa" +} diff --git a/.sqlx/query-0e894c84befe397687d4820ea313aa937cf76286e98f7e66c342fb87a3896265.json b/.sqlx/query-0e894c84befe397687d4820ea313aa937cf76286e98f7e66c342fb87a3896265.json new file mode 100644 index 0000000..0e9e556 --- /dev/null +++ b/.sqlx/query-0e894c84befe397687d4820ea313aa937cf76286e98f7e66c342fb87a3896265.json @@ -0,0 +1,76 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n id,\n username,\n email,\n salt,\n password,\n joined,\n verified as \"verified!: bool\",\n follows,\n followers,\n permissions\n FROM Accounts WHERE username = $1;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "salt", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "password", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "joined", + "type_info": "Timestamp" + }, + { + "ordinal": 6, + "name": "verified!: bool", + "type_info": "Bool" + }, + { + "ordinal": 7, + "name": "follows", + "type_info": "Int8Array" + }, + { + "ordinal": 8, + "name": "followers", + "type_info": "Int8Array" + }, + { + "ordinal": 9, + "name": "permissions", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + false, + true, + true, + false + ] + }, + "hash": "0e894c84befe397687d4820ea313aa937cf76286e98f7e66c342fb87a3896265" +} diff --git a/.sqlx/query-1a96696cf2ad271f7001e89ec733ba8437c308bf6125cad5f483efadd02722cb.json b/.sqlx/query-1a96696cf2ad271f7001e89ec733ba8437c308bf6125cad5f483efadd02722cb.json new file mode 100644 index 0000000..a0ac3d3 --- /dev/null +++ b/.sqlx/query-1a96696cf2ad271f7001e89ec733ba8437c308bf6125cad5f483efadd02722cb.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT * FROM VerificationTokens WHERE token = $1;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "token", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "account", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "expire", + "type_info": "Timestamp" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "1a96696cf2ad271f7001e89ec733ba8437c308bf6125cad5f483efadd02722cb" +} diff --git a/.sqlx/query-371fb1eff8cebe11d8527bda9ac27b2063cee27f9bad1b06cceaa3b95e93664c.json b/.sqlx/query-371fb1eff8cebe11d8527bda9ac27b2063cee27f9bad1b06cceaa3b95e93664c.json new file mode 100644 index 0000000..38a14bf --- /dev/null +++ b/.sqlx/query-371fb1eff8cebe11d8527bda9ac27b2063cee27f9bad1b06cceaa3b95e93664c.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO VerificationTokens (token, account, expire) VALUES ($1, $2, $3);\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Int8", + "Timestamp" + ] + }, + "nullable": [] + }, + "hash": "371fb1eff8cebe11d8527bda9ac27b2063cee27f9bad1b06cceaa3b95e93664c" +} diff --git a/.sqlx/query-3b0db22c46875b6cc12eb1710ef7446a300e19a13e75cea465ed5bafa5169416.json b/.sqlx/query-3b0db22c46875b6cc12eb1710ef7446a300e19a13e75cea465ed5bafa5169416.json new file mode 100644 index 0000000..a6520d0 --- /dev/null +++ b/.sqlx/query-3b0db22c46875b6cc12eb1710ef7446a300e19a13e75cea465ed5bafa5169416.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM AuthTokens WHERE token = $1;", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "3b0db22c46875b6cc12eb1710ef7446a300e19a13e75cea465ed5bafa5169416" +} diff --git a/.sqlx/query-5a65288ceaee7044d547a04600d50408249ae7f03356121968abf1039407ec3e.json b/.sqlx/query-5a65288ceaee7044d547a04600d50408249ae7f03356121968abf1039407ec3e.json new file mode 100644 index 0000000..b18b87f --- /dev/null +++ b/.sqlx/query-5a65288ceaee7044d547a04600d50408249ae7f03356121968abf1039407ec3e.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n CREATE TABLE IF NOT EXISTS Projects (\n id SERIAL8 NOT NULL,\n name VARCHAR(32) NOT NULL,\n desription TEXT,\n created TIMESTAMP NOT NULL,\n members BIGINT[][] NOT NULL,\n PRIMARY KEY(id)\n );\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "5a65288ceaee7044d547a04600d50408249ae7f03356121968abf1039407ec3e" +} diff --git a/.sqlx/query-699dbb92baf5954e5457dbd2dfded021c2436e57112259a8b0e208e4aa7628ae.json b/.sqlx/query-699dbb92baf5954e5457dbd2dfded021c2436e57112259a8b0e208e4aa7628ae.json new file mode 100644 index 0000000..216b469 --- /dev/null +++ b/.sqlx/query-699dbb92baf5954e5457dbd2dfded021c2436e57112259a8b0e208e4aa7628ae.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n CREATE TABLE IF NOT EXISTS Accounts (\n id SERIAL8 NOT NULL,\n\t username VARCHAR(32) NOT NULL,\n email TEXT NOT NULL,\n\t salt VARCHAR(22) NOT NULL,\n\t password VARCHAR(96) NOT NULL,\n joined TIMESTAMP NOT NULL,\n verified BOOLEAN NOT NULL,\n follows BIGINT[],\n followers BIGINT[],\n permissions BIGINT NOT NULL,\n\t PRIMARY KEY(id)\n );\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "699dbb92baf5954e5457dbd2dfded021c2436e57112259a8b0e208e4aa7628ae" +} diff --git a/.sqlx/query-6c470deaeaf19e799df3889436de40b0c863578fbafd7096613cde631f4ed7f4.json b/.sqlx/query-6c470deaeaf19e799df3889436de40b0c863578fbafd7096613cde631f4ed7f4.json new file mode 100644 index 0000000..5e649d7 --- /dev/null +++ b/.sqlx/query-6c470deaeaf19e799df3889436de40b0c863578fbafd7096613cde631f4ed7f4.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM VerificationTokens WHERE token = $1;", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "6c470deaeaf19e799df3889436de40b0c863578fbafd7096613cde631f4ed7f4" +} diff --git a/.sqlx/query-7009cdfba0b6c8d7c8ed9d49bf91905d159c3bbfe0c8e78876a8cd2b952e28b5.json b/.sqlx/query-7009cdfba0b6c8d7c8ed9d49bf91905d159c3bbfe0c8e78876a8cd2b952e28b5.json new file mode 100644 index 0000000..c08a556 --- /dev/null +++ b/.sqlx/query-7009cdfba0b6c8d7c8ed9d49bf91905d159c3bbfe0c8e78876a8cd2b952e28b5.json @@ -0,0 +1,76 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n id,\n username,\n email,\n salt,\n password,\n joined,\n verified as \"verified!: bool\",\n follows,\n followers,\n permissions\n FROM Accounts WHERE id = $1;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "salt", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "password", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "joined", + "type_info": "Timestamp" + }, + { + "ordinal": 6, + "name": "verified!: bool", + "type_info": "Bool" + }, + { + "ordinal": 7, + "name": "follows", + "type_info": "Int8Array" + }, + { + "ordinal": 8, + "name": "followers", + "type_info": "Int8Array" + }, + { + "ordinal": 9, + "name": "permissions", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + false, + true, + true, + false + ] + }, + "hash": "7009cdfba0b6c8d7c8ed9d49bf91905d159c3bbfe0c8e78876a8cd2b952e28b5" +} diff --git a/.sqlx/query-71b834dfe4384a536257b888e293b046a70aefd4ac2dcbf3268e34c9576e903e.json b/.sqlx/query-71b834dfe4384a536257b888e293b046a70aefd4ac2dcbf3268e34c9576e903e.json new file mode 100644 index 0000000..fe096c9 --- /dev/null +++ b/.sqlx/query-71b834dfe4384a536257b888e293b046a70aefd4ac2dcbf3268e34c9576e903e.json @@ -0,0 +1,76 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT\n id,\n username,\n email,\n salt,\n password,\n joined,\n verified as \"verified!: bool\",\n follows,\n followers,\n permissions\n FROM Accounts WHERE email = $1;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Text" + }, + { + "ordinal": 3, + "name": "salt", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "password", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "joined", + "type_info": "Timestamp" + }, + { + "ordinal": 6, + "name": "verified!: bool", + "type_info": "Bool" + }, + { + "ordinal": 7, + "name": "follows", + "type_info": "Int8Array" + }, + { + "ordinal": 8, + "name": "followers", + "type_info": "Int8Array" + }, + { + "ordinal": 9, + "name": "permissions", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false, + false, + true, + true, + false + ] + }, + "hash": "71b834dfe4384a536257b888e293b046a70aefd4ac2dcbf3268e34c9576e903e" +} diff --git a/.sqlx/query-8b37c356c1df9961b47359a56f69b658adafa9c58b79e6dd867f6e4f62fbd144.json b/.sqlx/query-8b37c356c1df9961b47359a56f69b658adafa9c58b79e6dd867f6e4f62fbd144.json new file mode 100644 index 0000000..c55d4bf --- /dev/null +++ b/.sqlx/query-8b37c356c1df9961b47359a56f69b658adafa9c58b79e6dd867f6e4f62fbd144.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO Accounts (username, email, salt, password, joined, verified, permissions) VALUES ($1, $2, $3, $4, $5, false, 0);", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text", + "Varchar", + "Varchar", + "Timestamp" + ] + }, + "nullable": [] + }, + "hash": "8b37c356c1df9961b47359a56f69b658adafa9c58b79e6dd867f6e4f62fbd144" +} diff --git a/.sqlx/query-994b743e8d80be58b6b41f4fd0f7daae3b3c34aa59093878a7d20a2598269a34.json b/.sqlx/query-994b743e8d80be58b6b41f4fd0f7daae3b3c34aa59093878a7d20a2598269a34.json new file mode 100644 index 0000000..ea02524 --- /dev/null +++ b/.sqlx/query-994b743e8d80be58b6b41f4fd0f7daae3b3c34aa59093878a7d20a2598269a34.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT * FROM AuthTokens WHERE account = $1;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "token", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "account", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "expire", + "type_info": "Timestamp" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "994b743e8d80be58b6b41f4fd0f7daae3b3c34aa59093878a7d20a2598269a34" +} diff --git a/.sqlx/query-af7d6e7978039e8493371a2f520d0e3b4494401e59650c06b6332557d51e5452.json b/.sqlx/query-af7d6e7978039e8493371a2f520d0e3b4494401e59650c06b6332557d51e5452.json new file mode 100644 index 0000000..dabbf6c --- /dev/null +++ b/.sqlx/query-af7d6e7978039e8493371a2f520d0e3b4494401e59650c06b6332557d51e5452.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM Accounts WHERE id = $1;", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "af7d6e7978039e8493371a2f520d0e3b4494401e59650c06b6332557d51e5452" +} diff --git a/.sqlx/query-bae0e81b05f7f2118beac49a2691e8a8466ed37c2c22e5d40d9aeb7da0f7ce59.json b/.sqlx/query-bae0e81b05f7f2118beac49a2691e8a8466ed37c2c22e5d40d9aeb7da0f7ce59.json new file mode 100644 index 0000000..dfd5c08 --- /dev/null +++ b/.sqlx/query-bae0e81b05f7f2118beac49a2691e8a8466ed37c2c22e5d40d9aeb7da0f7ce59.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT * FROM AuthTokens WHERE token = $1;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "token", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "account", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "expire", + "type_info": "Timestamp" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "bae0e81b05f7f2118beac49a2691e8a8466ed37c2c22e5d40d9aeb7da0f7ce59" +} diff --git a/.sqlx/query-d703f0f7593a46686b6b2d44bdaa3f9adcfd54c3fce5a7a35c87aba3937e794c.json b/.sqlx/query-d703f0f7593a46686b6b2d44bdaa3f9adcfd54c3fce5a7a35c87aba3937e794c.json new file mode 100644 index 0000000..5e8737b --- /dev/null +++ b/.sqlx/query-d703f0f7593a46686b6b2d44bdaa3f9adcfd54c3fce5a7a35c87aba3937e794c.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "DELETE FROM AuthTokens WHERE account = $1;", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [] + }, + "hash": "d703f0f7593a46686b6b2d44bdaa3f9adcfd54c3fce5a7a35c87aba3937e794c" +} diff --git a/.sqlx/query-d71ba18cd27ffc0b3ec7d6fb3e00fb0d56d2e02f4aba71e090ac0451b50cf56b.json b/.sqlx/query-d71ba18cd27ffc0b3ec7d6fb3e00fb0d56d2e02f4aba71e090ac0451b50cf56b.json new file mode 100644 index 0000000..335eb7c --- /dev/null +++ b/.sqlx/query-d71ba18cd27ffc0b3ec7d6fb3e00fb0d56d2e02f4aba71e090ac0451b50cf56b.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO AuthTokens (token, account, expire) VALUES ($1, $2, $3);\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Int8", + "Timestamp" + ] + }, + "nullable": [] + }, + "hash": "d71ba18cd27ffc0b3ec7d6fb3e00fb0d56d2e02f4aba71e090ac0451b50cf56b" +} diff --git a/.sqlx/query-d7aa893f2cd4154c72883bf50a031bdd1083c402c2409388f522767bbcdc2806.json b/.sqlx/query-d7aa893f2cd4154c72883bf50a031bdd1083c402c2409388f522767bbcdc2806.json new file mode 100644 index 0000000..9a96940 --- /dev/null +++ b/.sqlx/query-d7aa893f2cd4154c72883bf50a031bdd1083c402c2409388f522767bbcdc2806.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n CREATE TABLE IF NOT EXISTS VerificationTokens (\n token VARCHAR(32) NOT NULL,\n account SERIAL8 NOT NULL,\n expire TIMESTAMP NOT NULL\n );\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "d7aa893f2cd4154c72883bf50a031bdd1083c402c2409388f522767bbcdc2806" +} diff --git a/.sqlx/query-d89d2c78b57727c5fcdc45dcb7ae9fc3ea098706d958721495dafbe40628251a.json b/.sqlx/query-d89d2c78b57727c5fcdc45dcb7ae9fc3ea098706d958721495dafbe40628251a.json new file mode 100644 index 0000000..933c33e --- /dev/null +++ b/.sqlx/query-d89d2c78b57727c5fcdc45dcb7ae9fc3ea098706d958721495dafbe40628251a.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT * FROM VerificationTokens WHERE account = $1;", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "token", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "account", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "expire", + "type_info": "Timestamp" + } + ], + "parameters": { + "Left": [ + "Int8" + ] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "d89d2c78b57727c5fcdc45dcb7ae9fc3ea098706d958721495dafbe40628251a" +} diff --git a/.sqlx/query-f77dc2bcb3826a98bebee9bbcb3117953f781bd3f3f2afe6fd0b266da541df8c.json b/.sqlx/query-f77dc2bcb3826a98bebee9bbcb3117953f781bd3f3f2afe6fd0b266da541df8c.json new file mode 100644 index 0000000..a9226d3 --- /dev/null +++ b/.sqlx/query-f77dc2bcb3826a98bebee9bbcb3117953f781bd3f3f2afe6fd0b266da541df8c.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n CREATE TABLE IF NOT EXISTS AuthTokens (\n token VARCHAR(32) NOT NULL,\n account SERIAL8 NOT NULL,\n expire TIMESTAMP NOT NULL\n );\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "f77dc2bcb3826a98bebee9bbcb3117953f781bd3f3f2afe6fd0b266da541df8c" +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aca8580 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM rust:latest as build + +RUN apt-get update; \ + apt-get install -y libclang-dev automake autoconf + +# 1. Create a new empty shell project +RUN USER=root cargo new --bin nerdcult_api +WORKDIR /nerdcult_api + +# 2. Copy our manifests +COPY ./Cargo.lock ./Cargo.lock +COPY ./Cargo.toml ./Cargo.toml + +# 3. Build only the dependencies to cache them +RUN cargo build --release +RUN rm src/*.rs + +# 4. Now that the dependency is built, copy your source code +COPY ./src ./src +COPY .sqlx .sqlx + +# 5. Build for release. +RUN rm ./target/release/deps/nerdcult_api* + +RUN SQLX_OFFLINE=true cargo build --release + +FROM debian:bookworm-slim + +COPY --from=build /nerdcult_api/target/release/nerdcult_api /bin/nerdcult_api + +CMD ["/bin/nerdcult_api"] diff --git a/docs/README.md b/docs/README.md index 9c746a8..5fe77e7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,6 +13,8 @@ The token for this can be aquired using the `/account/authenticate` endpoint. - [X] `/tokens` - [ ] `/follows` - [ ] `/followers` + - [ ] `/deactivate` + - [ ] `/activate` - `/user/` - [ ] `/info` - [ ] `/follow` diff --git a/src/api/account/calls.rs b/src/api/account/calls.rs index 125f5a5..df7f3ba 100644 --- a/src/api/account/calls.rs +++ b/src/api/account/calls.rs @@ -61,7 +61,7 @@ async fn authenticate( } #[delete("/account/delete")] -async fn delete(data: web::Data, auth: BearerAuth) -> impl Responder { +async fn delete(data: web::Data, auth: BearerAuth, body: web::Json) -> impl Responder { match handlers::delete(&data.pool, auth.token().to_string()).await { Ok(resp) => match resp { data::DeleteResponse::Success => HttpResponse::Ok().finish(), diff --git a/src/api/account/data.rs b/src/api/account/data.rs index ce8818b..f580f10 100644 --- a/src/api/account/data.rs +++ b/src/api/account/data.rs @@ -54,6 +54,11 @@ pub enum AuthenticateResponse { Blocked, } +#[derive(Debug, Deserialize)] +pub struct DeleteRequest { + reaseon: String, +} + #[derive(Debug)] pub enum DeleteResponse { Success, diff --git a/src/api/mod.rs b/src/api/mod.rs index dfe271c..916f1d2 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -81,7 +81,7 @@ pub async fn start(port: u16, pool: PgPool) -> Result<()> { .service(account::calls::tokens_get) .app_data(web::Data::new(ApiState { pool: pool.clone() })) }) - .bind(("127.0.0.1", port))? + .bind(("0.0.0.0", port))? .run() .await;