diff --git a/.env b/.env new file mode 100644 index 0000000..c35b20c --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +DATABASE_URL=postgresql://mmap:yjhcfzXWrzslzl1331@8.217.64.157:5433/mmap +JWT_SECRET="JvGpWgGWLHAhvhxN7BuOVtUWfMXm6xAqjClaTwOcAnI=" +RUST_LOG=debug +PORT=3050 \ No newline at end of file diff --git a/.sqlx/query-0325b8932e0a71f18e0018185b5559eb6ec748c67417efaf62520a690ca2b385.json b/.sqlx/query-0325b8932e0a71f18e0018185b5559eb6ec748c67417efaf62520a690ca2b385.json new file mode 100644 index 0000000..9ee8168 --- /dev/null +++ b/.sqlx/query-0325b8932e0a71f18e0018185b5559eb6ec748c67417efaf62520a690ca2b385.json @@ -0,0 +1,64 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, code, created_by, used_by, is_used, expires_at, created_at, used_at\n FROM invite_codes \n WHERE id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "code", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "created_by", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "used_by", + "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "is_used", + "type_info": "Bool" + }, + { + "ordinal": 5, + "name": "expires_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "used_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + true, + false, + true, + true, + true + ] + }, + "hash": "0325b8932e0a71f18e0018185b5559eb6ec748c67417efaf62520a690ca2b385" +} diff --git a/.sqlx/query-18a1c337af1a4308cac915ab8161c8e5a19b1e798d91445bdeeed8235210fcc4.json b/.sqlx/query-18a1c337af1a4308cac915ab8161c8e5a19b1e798d91445bdeeed8235210fcc4.json new file mode 100644 index 0000000..9c1405c --- /dev/null +++ b/.sqlx/query-18a1c337af1a4308cac915ab8161c8e5a19b1e798d91445bdeeed8235210fcc4.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT value FROM system_config WHERE key = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "value", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "18a1c337af1a4308cac915ab8161c8e5a19b1e798d91445bdeeed8235210fcc4" +} diff --git a/.sqlx/query-238508bcec88a825c8bd87965aed4ccc3ce313835d9ed49d111b2722e207bd62.json b/.sqlx/query-238508bcec88a825c8bd87965aed4ccc3ce313835d9ed49d111b2722e207bd62.json new file mode 100644 index 0000000..d044dab --- /dev/null +++ b/.sqlx/query-238508bcec88a825c8bd87965aed4ccc3ce313835d9ed49d111b2722e207bd62.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO system_config (key, value) \n VALUES ($1, $2)\n ON CONFLICT (key) \n DO UPDATE SET value = $2, updated_at = NOW()\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Varchar", + "Text" + ] + }, + "nullable": [] + }, + "hash": "238508bcec88a825c8bd87965aed4ccc3ce313835d9ed49d111b2722e207bd62" +} diff --git a/.sqlx/query-2ab074bca985746d32cb5d932c0012019486847c80eb12d5fccda6841a22613d.json b/.sqlx/query-2ab074bca985746d32cb5d932c0012019486847c80eb12d5fccda6841a22613d.json new file mode 100644 index 0000000..952089d --- /dev/null +++ b/.sqlx/query-2ab074bca985746d32cb5d932c0012019486847c80eb12d5fccda6841a22613d.json @@ -0,0 +1,64 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, username, email, password_hash, role as \"role: Role\", invite_code_id, created_at, updated_at\n FROM users WHERE username = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "password_hash", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "role: Role", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "invite_code_id", + "type_info": "Uuid" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + true, + true, + true + ] + }, + "hash": "2ab074bca985746d32cb5d932c0012019486847c80eb12d5fccda6841a22613d" +} diff --git a/.sqlx/query-353dee803eee3a4f1e68a8e5f391879128dfc59b963bd519e8dfb2fae24c6c3b.json b/.sqlx/query-353dee803eee3a4f1e68a8e5f391879128dfc59b963bd519e8dfb2fae24c6c3b.json new file mode 100644 index 0000000..8ec9925 --- /dev/null +++ b/.sqlx/query-353dee803eee3a4f1e68a8e5f391879128dfc59b963bd519e8dfb2fae24c6c3b.json @@ -0,0 +1,64 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, code, created_by, used_by, is_used, expires_at, created_at, used_at\n FROM invite_codes \n WHERE code = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "code", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "created_by", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "used_by", + "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "is_used", + "type_info": "Bool" + }, + { + "ordinal": 5, + "name": "expires_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "used_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + true, + false, + true, + true, + true + ] + }, + "hash": "353dee803eee3a4f1e68a8e5f391879128dfc59b963bd519e8dfb2fae24c6c3b" +} diff --git a/.sqlx/query-3923b5d03196cc7753417e1748eb1c85a8cd2f5f912ff98ced99506647d770a4.json b/.sqlx/query-3923b5d03196cc7753417e1748eb1c85a8cd2f5f912ff98ced99506647d770a4.json new file mode 100644 index 0000000..3855d38 --- /dev/null +++ b/.sqlx/query-3923b5d03196cc7753417e1748eb1c85a8cd2f5f912ff98ced99506647d770a4.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE invite_codes \n SET is_used = true, used_by = $1, used_at = NOW()\n WHERE code = $2 AND is_used = false\n RETURNING id\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "3923b5d03196cc7753417e1748eb1c85a8cd2f5f912ff98ced99506647d770a4" +} diff --git a/.sqlx/query-3bdc7146e0751bcb04a3ed6831c0d094a5d4b38937542f5f1529748c8c6b3aa6.json b/.sqlx/query-3bdc7146e0751bcb04a3ed6831c0d094a5d4b38937542f5f1529748c8c6b3aa6.json new file mode 100644 index 0000000..f1b8a37 --- /dev/null +++ b/.sqlx/query-3bdc7146e0751bcb04a3ed6831c0d094a5d4b38937542f5f1529748c8c6b3aa6.json @@ -0,0 +1,64 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, username, email, password_hash, role as \"role: Role\", invite_code_id, created_at, updated_at\n FROM users WHERE id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "password_hash", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "role: Role", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "invite_code_id", + "type_info": "Uuid" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + true, + true, + true + ] + }, + "hash": "3bdc7146e0751bcb04a3ed6831c0d094a5d4b38937542f5f1529748c8c6b3aa6" +} diff --git a/.sqlx/query-41e05b2ce23645a612d385f0faa02dad038c2facb9cb1d566fe7572d659c0a03.json b/.sqlx/query-41e05b2ce23645a612d385f0faa02dad038c2facb9cb1d566fe7572d659c0a03.json new file mode 100644 index 0000000..7901b81 --- /dev/null +++ b/.sqlx/query-41e05b2ce23645a612d385f0faa02dad038c2facb9cb1d566fe7572d659c0a03.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM users WHERE is_activate = false", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "41e05b2ce23645a612d385f0faa02dad038c2facb9cb1d566fe7572d659c0a03" +} diff --git a/.sqlx/query-56c6cd9cd434821ad87afdc1e0e9194d1965d2876676780275ecdb45ee9e16f5.json b/.sqlx/query-56c6cd9cd434821ad87afdc1e0e9194d1965d2876676780275ecdb45ee9e16f5.json new file mode 100644 index 0000000..1643473 --- /dev/null +++ b/.sqlx/query-56c6cd9cd434821ad87afdc1e0e9194d1965d2876676780275ecdb45ee9e16f5.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM users WHERE role = 'user'", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "56c6cd9cd434821ad87afdc1e0e9194d1965d2876676780275ecdb45ee9e16f5" +} diff --git a/.sqlx/query-6e1bf3857d6eb4df7f14d0eca0823f39c50f1b18e61bc469d616598a20c5bb91.json b/.sqlx/query-6e1bf3857d6eb4df7f14d0eca0823f39c50f1b18e61bc469d616598a20c5bb91.json new file mode 100644 index 0000000..4ebaa61 --- /dev/null +++ b/.sqlx/query-6e1bf3857d6eb4df7f14d0eca0823f39c50f1b18e61bc469d616598a20c5bb91.json @@ -0,0 +1,64 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id, code, created_by, used_by, is_used, expires_at, created_at, used_at\n FROM invite_codes \n WHERE created_by = $1\n ORDER BY created_at DESC\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "code", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "created_by", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "used_by", + "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "is_used", + "type_info": "Bool" + }, + { + "ordinal": 5, + "name": "expires_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "used_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + true, + false, + true, + true, + true + ] + }, + "hash": "6e1bf3857d6eb4df7f14d0eca0823f39c50f1b18e61bc469d616598a20c5bb91" +} diff --git a/.sqlx/query-751a432b1a28e71faa4f87c9c470d6ca5212ffcde18ddb574c9c6e705cc02b01.json b/.sqlx/query-751a432b1a28e71faa4f87c9c470d6ca5212ffcde18ddb574c9c6e705cc02b01.json new file mode 100644 index 0000000..5f5a18b --- /dev/null +++ b/.sqlx/query-751a432b1a28e71faa4f87c9c470d6ca5212ffcde18ddb574c9c6e705cc02b01.json @@ -0,0 +1,12 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE system_config \n SET value = 'true', updated_at = NOW()\n WHERE key = 'admin_initialized'\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [] + }, + "nullable": [] + }, + "hash": "751a432b1a28e71faa4f87c9c470d6ca5212ffcde18ddb574c9c6e705cc02b01" +} diff --git a/.sqlx/query-84af2d99fe5036ae0f0041aa539427312e89b9faba1c8b6900164fbd0f7a703e.json b/.sqlx/query-84af2d99fe5036ae0f0041aa539427312e89b9faba1c8b6900164fbd0f7a703e.json new file mode 100644 index 0000000..b1ae72d --- /dev/null +++ b/.sqlx/query-84af2d99fe5036ae0f0041aa539427312e89b9faba1c8b6900164fbd0f7a703e.json @@ -0,0 +1,65 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE users SET invite_code_id = $1 WHERE id = $2\n RETURNING id, username, email, password_hash, role as \"role: Role\", invite_code_id, created_at, updated_at\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "password_hash", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "role: Role", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "invite_code_id", + "type_info": "Uuid" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + true, + true, + true + ] + }, + "hash": "84af2d99fe5036ae0f0041aa539427312e89b9faba1c8b6900164fbd0f7a703e" +} diff --git a/.sqlx/query-8a1b2c956e1ff38b2a2a6179f5f7aaddd80dfef77ed05694ba17d7dedebac9dc.json b/.sqlx/query-8a1b2c956e1ff38b2a2a6179f5f7aaddd80dfef77ed05694ba17d7dedebac9dc.json new file mode 100644 index 0000000..a6d2689 --- /dev/null +++ b/.sqlx/query-8a1b2c956e1ff38b2a2a6179f5f7aaddd80dfef77ed05694ba17d7dedebac9dc.json @@ -0,0 +1,73 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO users (username, email, password_hash, role)\n VALUES ($1, $2, $3, $4)\n RETURNING id, username, email, password_hash, role as \"role: Role\", invite_code_id, is_activate, created_at, updated_at\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "password_hash", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "role: Role", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "invite_code_id", + "type_info": "Uuid" + }, + { + "ordinal": 6, + "name": "is_activate", + "type_info": "Bool" + }, + { + "ordinal": 7, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 8, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Varchar", + "Varchar", + "Varchar" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + true, + false, + true, + true + ] + }, + "hash": "8a1b2c956e1ff38b2a2a6179f5f7aaddd80dfef77ed05694ba17d7dedebac9dc" +} diff --git a/.sqlx/query-9f0ea2fedffe65fa3211fc80bccfa7856d05ea48646879b8dd3579e45e4b6131.json b/.sqlx/query-9f0ea2fedffe65fa3211fc80bccfa7856d05ea48646879b8dd3579e45e4b6131.json new file mode 100644 index 0000000..238015a --- /dev/null +++ b/.sqlx/query-9f0ea2fedffe65fa3211fc80bccfa7856d05ea48646879b8dd3579e45e4b6131.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT value FROM system_config WHERE key = 'admin_initialized'\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "value", + "type_info": "Text" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false + ] + }, + "hash": "9f0ea2fedffe65fa3211fc80bccfa7856d05ea48646879b8dd3579e45e4b6131" +} diff --git a/.sqlx/query-a27168afd0caa5f71fa1036e2508d0a7f83a74433a42d7a31c71a97c522aed79.json b/.sqlx/query-a27168afd0caa5f71fa1036e2508d0a7f83a74433a42d7a31c71a97c522aed79.json new file mode 100644 index 0000000..731e9ed --- /dev/null +++ b/.sqlx/query-a27168afd0caa5f71fa1036e2508d0a7f83a74433a42d7a31c71a97c522aed79.json @@ -0,0 +1,65 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id, username, email, password_hash, role as \"role: Role\", invite_code_id, created_at, updated_at FROM users LIMIT $1 OFFSET $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "password_hash", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "role: Role", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "invite_code_id", + "type_info": "Uuid" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + true, + true, + true + ] + }, + "hash": "a27168afd0caa5f71fa1036e2508d0a7f83a74433a42d7a31c71a97c522aed79" +} diff --git a/.sqlx/query-c2c999a6ab3b058deced5568868eff7e70cf981804cecd228b6477885e1386ae.json b/.sqlx/query-c2c999a6ab3b058deced5568868eff7e70cf981804cecd228b6477885e1386ae.json new file mode 100644 index 0000000..bc1ee7c --- /dev/null +++ b/.sqlx/query-c2c999a6ab3b058deced5568868eff7e70cf981804cecd228b6477885e1386ae.json @@ -0,0 +1,67 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO users (username, email, password_hash, role)\n VALUES ($1, $2, $3, $4)\n RETURNING id, username, email, password_hash, role as \"role: Role\", invite_code_id, created_at, updated_at\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "username", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "email", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "password_hash", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "role: Role", + "type_info": "Varchar" + }, + { + "ordinal": 5, + "name": "invite_code_id", + "type_info": "Uuid" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "updated_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Varchar", + "Varchar", + "Varchar" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + true, + true, + true + ] + }, + "hash": "c2c999a6ab3b058deced5568868eff7e70cf981804cecd228b6477885e1386ae" +} diff --git a/.sqlx/query-d470eafcaff0b536c38e0d29a1a4f35867068c68ebed4b326517631a8e978da5.json b/.sqlx/query-d470eafcaff0b536c38e0d29a1a4f35867068c68ebed4b326517631a8e978da5.json new file mode 100644 index 0000000..90cf407 --- /dev/null +++ b/.sqlx/query-d470eafcaff0b536c38e0d29a1a4f35867068c68ebed4b326517631a8e978da5.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM users WHERE is_activate = true", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "d470eafcaff0b536c38e0d29a1a4f35867068c68ebed4b326517631a8e978da5" +} diff --git a/.sqlx/query-d4a34771ec58927f36305a1e5de9b1d6006b44eaf693f666cf63923d322c987f.json b/.sqlx/query-d4a34771ec58927f36305a1e5de9b1d6006b44eaf693f666cf63923d322c987f.json new file mode 100644 index 0000000..921d485 --- /dev/null +++ b/.sqlx/query-d4a34771ec58927f36305a1e5de9b1d6006b44eaf693f666cf63923d322c987f.json @@ -0,0 +1,23 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT create_invite_code($1, $2)", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "create_invite_code", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int4" + ] + }, + "nullable": [ + null + ] + }, + "hash": "d4a34771ec58927f36305a1e5de9b1d6006b44eaf693f666cf63923d322c987f" +} diff --git a/.sqlx/query-d718520b0f79dd1b0999cbb65bd334dca8d7209fa914355a38287af587ae8d4c.json b/.sqlx/query-d718520b0f79dd1b0999cbb65bd334dca8d7209fa914355a38287af587ae8d4c.json new file mode 100644 index 0000000..bd5b3ef --- /dev/null +++ b/.sqlx/query-d718520b0f79dd1b0999cbb65bd334dca8d7209fa914355a38287af587ae8d4c.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM users WHERE role = 'admin'", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "d718520b0f79dd1b0999cbb65bd334dca8d7209fa914355a38287af587ae8d4c" +} diff --git a/.sqlx/query-dc64e1d25d9ced3a49130cee99f6edc3f70a4917910cf3b76faefc24ac32159d.json b/.sqlx/query-dc64e1d25d9ced3a49130cee99f6edc3f70a4917910cf3b76faefc24ac32159d.json new file mode 100644 index 0000000..c958e8d --- /dev/null +++ b/.sqlx/query-dc64e1d25d9ced3a49130cee99f6edc3f70a4917910cf3b76faefc24ac32159d.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COUNT(*) FROM users", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "count", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "dc64e1d25d9ced3a49130cee99f6edc3f70a4917910cf3b76faefc24ac32159d" +} diff --git a/Cargo.lock b/Cargo.lock index 4c68f06..a22c379 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,16 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "addr2line" version = "0.24.2" @@ -17,6 +27,189 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "argon2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" +dependencies = [ + "base64ct", + "blake2", + "cpufeatures", + "password-hash", +] + +[[package]] +name = "ascii_utils" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a" + +[[package]] +name = "async-graphql" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "036618f842229ba0b89652ffe425f96c7c16a49f7e3cb23b56fca7f61fd74980" +dependencies = [ + "async-graphql-derive", + "async-graphql-parser", + "async-graphql-value", + "async-stream", + "async-trait", + "base64", + "bytes", + "chrono", + "fast_chemail", + "fnv", + "futures-timer", + "futures-util", + "handlebars", + "http", + "indexmap", + "mime", + "multer", + "num-traits", + "pin-project-lite", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "static_assertions_next", + "tempfile", + "thiserror 1.0.69", + "uuid", +] + +[[package]] +name = "async-graphql-axum" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8725874ecfbf399e071150b8619c4071d7b2b7a2f117e173dddef53c6bdb6bb1" +dependencies = [ + "async-graphql", + "axum", + "bytes", + "futures-util", + "serde_json", + "tokio", + "tokio-stream", + "tokio-util", + "tower-service", +] + +[[package]] +name = "async-graphql-derive" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd45deb3dbe5da5cdb8d6a670a7736d735ba65b455328440f236dfb113727a3d" +dependencies = [ + "Inflector", + "async-graphql-parser", + "darling", + "proc-macro-crate", + "proc-macro2", + "quote", + "strum", + "syn", + "thiserror 1.0.69", +] + +[[package]] +name = "async-graphql-parser" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b7607e59424a35dadbc085b0d513aa54ec28160ee640cf79ec3b634eba66d3" +dependencies = [ + "async-graphql-value", + "pest", + "serde", + "serde_json", +] + +[[package]] +name = "async-graphql-value" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ecdaff7c9cffa3614a9f9999bf9ee4c3078fe3ce4d6a6e161736b56febf2de" +dependencies = [ + "bytes", + "indexmap", + "serde", + "serde_json", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + [[package]] name = "autocfg" version = "1.5.0" @@ -30,6 +223,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5" dependencies = [ "axum-core", + "axum-macros", + "base64", "bytes", "form_urlencoded", "futures-util", @@ -49,9 +244,11 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", + "sha1", "sync_wrapper", "tokio", - "tower", + "tokio-tungstenite", + "tower 0.5.2", "tower-layer", "tower-service", "tracing", @@ -77,6 +274,60 @@ dependencies = [ "tracing", ] +[[package]] +name = "axum-extra" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bf463831f5131b7d3c756525b305d40f1185b688565648a92e1392ca35713d" +dependencies = [ + "axum", + "axum-core", + "bytes", + "futures-util", + "headers", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "serde", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-jwt-auth" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418f97e310fb4e9bc5c38948ede899a2aa00911529aaf69ff38c454f4a653397" +dependencies = [ + "async-trait", + "axum", + "axum-extra", + "dashmap", + "derive_builder", + "futures", + "jsonwebtoken", + "reqwest", + "serde", + "thiserror 2.0.12", + "tokio", + "tracing", +] + +[[package]] +name = "axum-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "backtrace" version = "0.3.75" @@ -89,20 +340,77 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" + [[package]] name = "bitflags" version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +dependencies = [ + "serde", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +dependencies = [ + "serde", +] + +[[package]] +name = "cc" +version = "1.2.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -110,12 +418,326 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9710d3b3739c2e349eb44fe848ad0b7c8cb1e42bd87ee49371df2f7acaf3e675" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "data-encoding" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +dependencies = [ + "serde", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "fast_chemail" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "495a39d30d624c2caabe6312bfead73e7717692b44e0b32df168c275a2e8e9e4" +dependencies = [ + "ascii_utils", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -125,6 +747,21 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.31" @@ -132,6 +769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -140,22 +778,116 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + [[package]] name = "futures-task" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" + [[package]] name = "futures-util" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", ] [[package]] @@ -164,6 +896,109 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "handlebars" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hashbrown" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.4", +] + +[[package]] +name = "headers" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3314d5adb5d94bcdf56771f2e50dbbc80bb4bdf88967526706205ac9eff24eb" +dependencies = [ + "base64", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" +dependencies = [ + "http", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "http" version = "1.3.1" @@ -227,6 +1062,24 @@ dependencies = [ "pin-project-lite", "smallvec", "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots 1.0.2", ] [[package]] @@ -235,14 +1088,170 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df" dependencies = [ + "base64", "bytes", + "futures-channel", "futures-core", + "futures-util", "http", "http-body", "hyper", + "ipnet", + "libc", + "percent-encoding", "pin-project-lite", + "socket2", "tokio", "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" + +[[package]] +name = "icu_properties" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "potential_utf", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" + +[[package]] +name = "icu_provider" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +dependencies = [ + "displaydoc", + "icu_locale_core", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +dependencies = [ + "equivalent", + "hashbrown 0.15.4", + "serde", ] [[package]] @@ -256,17 +1265,61 @@ dependencies = [ "libc", ] +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "jsonwebtoken" +version = "9.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde" +dependencies = [ + "base64", + "js-sys", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] [[package]] name = "libc" @@ -274,6 +1327,34 @@ version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "litemap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" + [[package]] name = "lock_api" version = "0.4.13" @@ -290,16 +1371,34 @@ version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + [[package]] name = "mapp" version = "0.1.0" dependencies = [ + "argon2", + "async-graphql", + "async-graphql-axum", + "async-stream", "axum", + "axum-jwt-auth", + "chrono", + "dotenvy", + "futures-util", + "jsonwebtoken", "serde", + "sqlx", "tokio", - "tower-http", + "tower 0.4.13", + "tower-http 0.5.2", "tracing", "tracing-subscriber", + "uuid", ] [[package]] @@ -308,6 +1407,16 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + [[package]] name = "memchr" version = "2.7.5" @@ -336,10 +1445,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", - "wasi", + "wasi 0.11.1+wasi-snapshot-preview1", "windows-sys 0.59.0", ] +[[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "memchr", + "mime", + "spin", + "version_check", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -350,6 +1476,69 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + [[package]] name = "object" version = "0.36.7" @@ -371,6 +1560,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + [[package]] name = "parking_lot" version = "0.12.4" @@ -391,7 +1586,37 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "pem" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" +dependencies = [ + "base64", + "serde", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", ] [[package]] @@ -400,6 +1625,50 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pest" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" +dependencies = [ + "memchr", + "thiserror 2.0.12", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" +dependencies = [ + "pest", + "sha2", +] + [[package]] name = "pin-project-lite" version = "0.2.16" @@ -412,6 +1681,66 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro-crate" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.95" @@ -421,6 +1750,61 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quinn" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626214629cda6781b6dc1d316ba307189c85ba657213ce642d9c77670f8202c8" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.12", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e" +dependencies = [ + "bytes", + "getrandom 0.3.3", + "lru-slab", + "rand 0.9.2", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.12", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcebb1209ee276352ef14ff8732e24cc2b02bbac986cd74a4c81bcb2f9881970" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.59.0", +] + [[package]] name = "quote" version = "1.0.40" @@ -430,6 +1814,71 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.16", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.3", +] + [[package]] name = "redox_syscall" version = "0.5.13" @@ -439,12 +1888,167 @@ dependencies = [ "bitflags", ] +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reqwest" +version = "0.12.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531" +dependencies = [ + "base64", + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower 0.5.2", + "tower-http 0.6.6", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots 1.0.2", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rsa" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78928ac1ed176a5ca1d17e578a1825f3d81ca54cf41053a592584b020cfd691b" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rustc-demangle" version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustls" +version = "0.23.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.21" @@ -517,6 +2121,28 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -526,6 +2152,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.5" @@ -535,6 +2167,28 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + +[[package]] +name = "simple_asn1" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror 2.0.12", + "time", +] + [[package]] name = "slab" version = "0.4.10" @@ -546,6 +2200,9 @@ name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +dependencies = [ + "serde", +] [[package]] name = "socket2" @@ -557,6 +2214,280 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlx" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" +dependencies = [ + "base64", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.15.4", + "hashlink", + "indexmap", + "log", + "memchr", + "once_cell", + "percent-encoding", + "rustls", + "serde", + "serde_json", + "sha2", + "smallvec", + "thiserror 2.0.12", + "tokio", + "tokio-stream", + "tracing", + "url", + "uuid", + "webpki-roots 0.26.11", +] + +[[package]] +name = "sqlx-macros" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b" +dependencies = [ + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "bytes", + "chrono", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand 0.8.5", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror 2.0.12", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand 0.8.5", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror 2.0.12", + "tracing", + "uuid", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea" +dependencies = [ + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "serde_urlencoded", + "sqlx-core", + "thiserror 2.0.12", + "tracing", + "url", + "uuid", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions_next" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7beae5182595e9a8b683fa98c4317f956c9a2dec3b9716990d20023cc60c766" + +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.104" @@ -573,6 +2504,73 @@ name = "sync_wrapper" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +dependencies = [ + "fastrand", + "getrandom 0.3.3", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl 2.0.12", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "thread_local" @@ -583,6 +2581,62 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "time" +version = "0.3.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" + +[[package]] +name = "time-macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.46.1" @@ -614,6 +2668,81 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9daff607c6d2bf6c16fd681ccb7eecc83e4e2cdc1ca067ffaadfca5de7f084" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +dependencies = [ + "bytes", + "futures-core", + "futures-io", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower" version = "0.5.2" @@ -630,6 +2759,22 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower-http" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" +dependencies = [ + "bitflags", + "bytes", + "http", + "http-body", + "http-body-util", + "pin-project-lite", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-http" version = "0.6.6" @@ -638,8 +2783,12 @@ checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" dependencies = [ "bitflags", "bytes", + "futures-util", "http", + "http-body", + "iri-string", "pin-project-lite", + "tower 0.5.2", "tower-layer", "tower-service", ] @@ -714,24 +2863,276 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "tungstenite" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.9.2", + "sha1", + "thiserror 2.0.12", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +dependencies = [ + "getrandom 0.3.3", + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "valuable" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.2", +] + +[[package]] +name = "webpki-roots" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "whoami" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6994d13118ab492c3c80c1f81928718159254c53c472bf9ce36f8dae4add02a7" +dependencies = [ + "redox_syscall", + "wasite", +] + [[package]] name = "winapi" version = "0.3.9" @@ -754,13 +3155,81 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -769,7 +3238,22 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -778,28 +3262,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -812,26 +3314,178 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + +[[package]] +name = "writeable" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" + +[[package]] +name = "yoke" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index ec3f3bd..78c8899 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,30 @@ [package] name = "mapp" version = "0.1.0" -edition = "2024" +edition = "2021" [dependencies] -axum = "0.8.4" -serde = { version = "1.0.219", features = ["derive"] } -tokio = { version = "1.46.1", features = ["full"] } -tower-http = { version = "0.6.0", features = ["cors"] } -tracing = "0.1.40" -tracing-subscriber = "0.3.19" +async-graphql = { version = "7.0.17", features = ["chrono", "uuid"] } +async-graphql-axum = "7.0.17" +axum = { version = "0.8.4", features = ["ws", "macros"] } +chrono = { version = "0.4", features = ["serde"] } +serde = { version = "1.0", features = ["derive"] } +sqlx = { version = "0.8", features = [ + "runtime-tokio-rustls", + "postgres", + "chrono", + "uuid", + "migrate", +] } +tokio = { version = "1.0", features = ["full"] } +tower-http = { version = "0.5", features = ["cors"] } +tracing = "0.1" +tracing-subscriber = "0.3" +jsonwebtoken = "9.0" +argon2 = "0.5" +dotenvy = "0.15" +uuid = { version = "1.0", features = ["v4", "serde"] } +futures-util = "0.3" +tower = "0.4" +async-stream = "0.3" +axum-jwt-auth = "0.5.1" diff --git a/migrations/001_init.sql b/migrations/001_init.sql new file mode 100644 index 0000000..a8e637c --- /dev/null +++ b/migrations/001_init.sql @@ -0,0 +1,27 @@ +-- Create users table +CREATE TABLE users ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + username VARCHAR(255) NOT NULL UNIQUE, + email VARCHAR(255) NOT NULL UNIQUE, + password_hash VARCHAR(255) NOT NULL, + role VARCHAR(50) NOT NULL DEFAULT 'User', + created_at TIMESTAMPTZ DEFAULT NOW(), + updated_at TIMESTAMPTZ DEFAULT NOW() +); + +-- Create index on username and email for faster lookups +CREATE INDEX idx_users_username ON users(username); +CREATE INDEX idx_users_email ON users(email); + +-- Create function to update updated_at timestamp +CREATE OR REPLACE FUNCTION update_updated_at_column() +RETURNS TRIGGER AS $$ +BEGIN + NEW.updated_at = NOW(); + RETURN NEW; +END; +$$ language 'plpgsql'; + +-- Create trigger to automatically update updated_at +CREATE TRIGGER update_users_updated_at BEFORE UPDATE +ON users FOR EACH ROW EXECUTE FUNCTION update_updated_at_column(); \ No newline at end of file diff --git a/migrations/002_invite_codes.sql b/migrations/002_invite_codes.sql new file mode 100644 index 0000000..d839165 --- /dev/null +++ b/migrations/002_invite_codes.sql @@ -0,0 +1,59 @@ +-- Create invite_codes table +CREATE TABLE invite_codes ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + code VARCHAR(20) NOT NULL UNIQUE, + created_by UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, + used_by UUID REFERENCES users(id) ON DELETE SET NULL, + is_used BOOLEAN NOT NULL DEFAULT FALSE, + expires_at TIMESTAMPTZ, + created_at TIMESTAMPTZ DEFAULT NOW(), + used_at TIMESTAMPTZ +); + +-- Create indexes for better performance +CREATE INDEX idx_invite_codes_code ON invite_codes(code); +CREATE INDEX idx_invite_codes_created_by ON invite_codes(created_by); +CREATE INDEX idx_invite_codes_used_by ON invite_codes(used_by); +CREATE INDEX idx_invite_codes_is_used ON invite_codes(is_used); +CREATE INDEX idx_invite_codes_expires_at ON invite_codes(expires_at); + +-- Add invite_code_id column to users table +ALTER TABLE users ADD COLUMN invite_code_id UUID REFERENCES invite_codes(id) ON DELETE SET NULL; + +-- Create index on the new column +CREATE INDEX idx_users_invite_code_id ON users(invite_code_id); + +-- Create function to generate random invite codes +CREATE OR REPLACE FUNCTION generate_invite_code() +RETURNS VARCHAR(20) AS $$ +DECLARE + chars TEXT := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + result VARCHAR(20) := ''; + i INTEGER; +BEGIN + FOR i IN 1..8 LOOP + result := result || substr(chars, floor(random() * length(chars))::integer + 1, 1); + END LOOP; + RETURN result; +END; +$$ LANGUAGE plpgsql; + +-- Create function to create a new invite code +CREATE OR REPLACE FUNCTION create_invite_code(creator_id UUID, expires_in_days INTEGER DEFAULT 30) +RETURNS VARCHAR(20) AS $$ +DECLARE + new_code VARCHAR(20); + code_exists BOOLEAN; +BEGIN + LOOP + new_code := generate_invite_code(); + SELECT EXISTS(SELECT 1 FROM invite_codes WHERE code = new_code) INTO code_exists; + EXIT WHEN NOT code_exists; + END LOOP; + + INSERT INTO invite_codes (code, created_by, expires_at) + VALUES (new_code, creator_id, NOW() + (expires_in_days || ' days')::INTERVAL); + + RETURN new_code; +END; +$$ LANGUAGE plpgsql; \ No newline at end of file diff --git a/migrations/003_system_config.sql b/migrations/003_system_config.sql new file mode 100644 index 0000000..05baa53 --- /dev/null +++ b/migrations/003_system_config.sql @@ -0,0 +1,20 @@ +-- Create system_config table to track system-wide settings +CREATE TABLE system_config ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + key VARCHAR(255) NOT NULL UNIQUE, + value TEXT NOT NULL, + description TEXT, + created_at TIMESTAMPTZ DEFAULT NOW(), + updated_at TIMESTAMPTZ DEFAULT NOW() +); + +-- Create index on key for faster lookups +CREATE INDEX idx_system_config_key ON system_config(key); + +-- Create trigger to automatically update updated_at +CREATE TRIGGER update_system_config_updated_at BEFORE UPDATE +ON system_config FOR EACH ROW EXECUTE FUNCTION update_updated_at_column(); + +-- Insert initial system configuration +INSERT INTO system_config (key, value, description) +VALUES ('admin_initialized', 'false', 'Whether the first admin user has been initialized'); \ No newline at end of file diff --git a/migrations/004_add_user_is_activate.sql b/migrations/004_add_user_is_activate.sql new file mode 100644 index 0000000..043b915 --- /dev/null +++ b/migrations/004_add_user_is_activate.sql @@ -0,0 +1,8 @@ +-- Add is_activate column to users table +ALTER TABLE users ADD COLUMN is_activate BOOLEAN NOT NULL DEFAULT true; + +-- Create index on is_activate for faster filtering +CREATE INDEX idx_users_is_activate ON users(is_activate); + +-- Update existing users to be activated by default +UPDATE users SET is_activate = true WHERE is_activate IS NULL; \ No newline at end of file diff --git a/src/app.rs b/src/app.rs new file mode 100644 index 0000000..8b91b6d --- /dev/null +++ b/src/app.rs @@ -0,0 +1,99 @@ +use std::sync::Arc; + +use async_graphql::{ + http::{playground_source, GraphQLPlaygroundConfig}, + Schema, +}; +use async_graphql_axum::{GraphQLRequest, GraphQLResponse, GraphQLSubscription}; +use axum::{ + extract::{FromRef, State}, + response::{Html, IntoResponse}, + routing::{get, post}, + Router, +}; +use jsonwebtoken::DecodingKey; +use sqlx::PgPool; +use tower_http::cors::CorsLayer; + +use crate::{ + auth::{AuthUser, AuthUserState, Claims as MyClaims}, + config::Config, + graphql::{MutationRoot, QueryRoot, SubscriptionRoot}, + services::{ + invite_code_service::InviteCodeService, system_config_service::SystemConfigService, + user_service::UserService, + }, +}; + +use axum_jwt_auth::{Claims, JwtDecoderState, LocalDecoder}; +use jsonwebtoken::Validation; + +pub type AppSchema = Schema; + +#[derive(Clone, FromRef)] +pub struct AppState { + pub schema: AppSchema, + pub decoder: JwtDecoderState, +} + +pub fn create_router(pool: PgPool, config: Config) -> Router { + let user_service = UserService::new(pool.clone(), config.jwt_secret.clone()); + let invite_code_service = InviteCodeService::new(pool.clone()); + let system_config_service = SystemConfigService::new(pool.clone()); + + let schema = Schema::build(QueryRoot, MutationRoot, SubscriptionRoot) + .data(pool) + .data(user_service) + .data(invite_code_service) + .data(system_config_service) + .data(config.clone()) + .finish(); + + let keys = vec![DecodingKey::from_secret(config.jwt_secret.as_bytes())]; + let validation = Validation::default(); + let decoder = LocalDecoder::builder() + .keys(keys) + .validation(validation) + .build() + .unwrap(); + + let app_state = AppState { + schema, + decoder: JwtDecoderState { + decoder: Arc::new(decoder), + }, + }; + + Router::new() + .route("/", get(graphql_playground)) + .route("/graphql", get(graphql_playground).post(graphql_handler)) + // .route("/ws", get(graphql_subscription_handler)) + .layer(CorsLayer::permissive()) + .with_state(app_state) +} + +#[axum::debug_handler] +async fn graphql_handler( + AuthUserState(user): AuthUserState, + State(state): State, + req: GraphQLRequest, +) -> GraphQLResponse { + let mut request = req.into_inner(); + if let Some(user) = user { + request = request.data(user); + } + state.schema.execute(request).await.into() +} + +async fn graphql_playground() -> impl IntoResponse { + Html(playground_source(GraphQLPlaygroundConfig::new("/graphql"))) +} + +// async fn graphql_subscription_handler( +// State(state): State, +// ws: axum::extract::WebSocketUpgrade, +// ) -> Response { +// ws.on_upgrade(move |socket| async move { +// GraphQLSubscription::new(socket, state.schema).serve().await +// }) +// } diff --git a/src/auth.rs b/src/auth.rs new file mode 100644 index 0000000..baba12f --- /dev/null +++ b/src/auth.rs @@ -0,0 +1,163 @@ +use std::convert::Infallible; + +use async_graphql::{Context, Error, Result}; +use axum::{ + extract::FromRequestParts, + http::{request::Parts, StatusCode}, + RequestPartsExt, +}; +use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation}; +use serde::{Deserialize, Serialize}; +use uuid::Uuid; + +use crate::{ + models::user::{Role, User}, + services::user_service::UserService, +}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Claims { + pub sub: String, + pub username: String, + pub role: Role, + pub exp: usize, +} + +impl Claims { + pub fn new(user: &User, jwt_secret: &str) -> Result { + let expiration = chrono::Utc::now() + .checked_add_signed(chrono::Duration::hours(24)) + .unwrap() + .timestamp() as usize; + + let claims = Claims { + sub: user.id.to_string(), + username: user.username.clone(), + role: user.role, + exp: expiration, + }; + + encode( + &Header::default(), + &claims, + &EncodingKey::from_secret(jwt_secret.as_ref()), + ) + .map_err(|e| Error::new(format!("Failed to create token: {}", e))) + } + + pub fn verify(token: &str, jwt_secret: &str) -> Result { + decode::( + token, + &DecodingKey::from_secret(jwt_secret.as_ref()), + &Validation::default(), + ) + .map(|data| data.claims) + .map_err(|e| Error::new(format!("Invalid token: {}", e))) + } +} + +#[derive(Clone)] +pub struct AuthUserState(pub Option); + +impl FromRequestParts for AuthUserState +where + S: Send + Sync, +{ + type Rejection = Infallible; + + async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result { + let auth_header = parts + .headers + .get("Authorization") + .and_then(|header| header.to_str().ok()); + + let auth_header = match auth_header { + Some(header) => header, + None => return Ok(AuthUserState(None)), + }; + + if !auth_header.starts_with("Bearer ") { + return Ok(AuthUserState(None)); + } + + let token = &auth_header[7..]; + let jwt_secret = match std::env::var("JWT_SECRET") { + Ok(secret) => secret, + Err(_) => return Ok(AuthUserState(None)), + }; + + let claims = match Claims::verify(token, &jwt_secret) { + Ok(claims) => claims, + Err(_) => return Ok(AuthUserState(None)), + }; + + let id = match Uuid::parse_str(&claims.sub) { + Ok(id) => id, + Err(_) => return Ok(AuthUserState(None)), + }; + + Ok(AuthUserState(Some(AuthUser { + id, + username: claims.username, + role: claims.role, + }))) + } +} + +#[derive(Debug, Clone)] +pub struct AuthUser { + pub id: Uuid, + pub username: String, + pub role: Role, +} + +pub async fn get_auth_user<'a>(ctx: &'a Context<'_>) -> Result { + let claims = ctx + .data::() + .map_err(|_| Error::new("Authentication required"))?; + + let uid = &claims.id; + + let user = ctx + .data::() + .unwrap() + .get_user_by_id(*uid) + .await? + .map(|user| AuthUser { + id: user.id, + username: user.username, + role: user.role, + }) + .ok_or(Error::new("User not found"))?; + + Ok(user) +} + +// #[derive(Debug, Clone)] +// pub struct AuthUser { +// pub id: Uuid, +// pub username: String, +// pub role: Role, +// } + +// pub async fn get_auth_user<'a>(ctx: &'a Context<'_>) -> Result { +// let claims = ctx +// .data::() +// .map_err(|_| Error::new("Authentication required"))?; + +// let uid = &claims.sub; + +// let user = ctx +// .data::() +// .unwrap() +// .get_user_by_id(Uuid::parse_str(uid).unwrap()) +// .await? +// .map(|user| AuthUser { +// id: user.id, +// username: user.username, +// role: user.role, +// }) +// .ok_or(Error::new("User not found"))?; + +// Ok(user) +// } diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..31903e2 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,23 @@ +use std::env; + +#[derive(Debug, Clone)] +pub struct Config { + pub database_url: String, + pub jwt_secret: String, + pub port: u16, +} + +impl Config { + pub fn from_env() -> Result { + dotenvy::dotenv().ok(); + + Ok(Config { + database_url: env::var("DATABASE_URL")?, + jwt_secret: env::var("JWT_SECRET")?, + port: env::var("PORT") + .unwrap_or_else(|_| "3000".to_string()) + .parse() + .unwrap_or(3000), + }) + } +} \ No newline at end of file diff --git a/src/db.rs b/src/db.rs new file mode 100644 index 0000000..99fe9ed --- /dev/null +++ b/src/db.rs @@ -0,0 +1,14 @@ +use sqlx::{PgPool, postgres::PgPoolOptions}; +use std::time::Duration; + +pub async fn create_pool(database_url: &str) -> Result { + PgPoolOptions::new() + .max_connections(10) + .acquire_timeout(Duration::from_secs(30)) + .connect(database_url) + .await +} + +pub async fn run_migrations(pool: &PgPool) -> Result<(), sqlx::migrate::MigrateError> { + sqlx::migrate!("./migrations").run(pool).await +} \ No newline at end of file diff --git a/src/graphql/guards.rs b/src/graphql/guards.rs new file mode 100644 index 0000000..80b5772 --- /dev/null +++ b/src/graphql/guards.rs @@ -0,0 +1,20 @@ +use crate::auth::get_auth_user; +use crate::models::user::Role; +use async_graphql::{Context, Error, Guard, Result}; + +pub struct RequireRole(pub Role); + +impl Guard for RequireRole { + async fn check(&self, ctx: &Context<'_>) -> Result<()> { + let user = get_auth_user(ctx).await?; + + match (self.0, user.role) { + (Role::User, Role::User) | (Role::User, Role::Admin) => Ok(()), + (Role::Admin, Role::Admin) => Ok(()), + _ => Err(Error::new(format!( + "Insufficient permissions. Required: {:?}, Current: {:?}", + self.0, user.role + ))), + } + } +} diff --git a/src/graphql/mod.rs b/src/graphql/mod.rs new file mode 100644 index 0000000..c28df9a --- /dev/null +++ b/src/graphql/mod.rs @@ -0,0 +1,9 @@ +pub mod guards; +pub mod mutation; +pub mod query; +pub mod subscription; +pub mod types; + +pub use mutation::MutationRoot; +pub use query::QueryRoot; +pub use subscription::SubscriptionRoot; \ No newline at end of file diff --git a/src/graphql/mutation.rs b/src/graphql/mutation.rs new file mode 100644 index 0000000..f96a0e5 --- /dev/null +++ b/src/graphql/mutation.rs @@ -0,0 +1,83 @@ +use crate::auth::get_auth_user; +use crate::graphql::guards::RequireRole; +use crate::graphql::types::{ + CreateInviteCodeInput, CreateUserInput, InitializeAdminInput, InitializeAdminResponse, + InviteCodeResponse, LoginInput, LoginResponse, RegisterInput, +}; +use crate::models::user::Role; +use crate::models::user::User; +use crate::services::invite_code_service::InviteCodeService; +use crate::services::user_service::UserService; +use async_graphql::{Context, Object, Result}; + +pub struct MutationRoot; + +#[Object] +impl MutationRoot { + async fn register(&self, ctx: &Context<'_>, input: RegisterInput) -> Result { + let user_service = ctx.data::()?; + user_service.register(input).await + } + + #[graphql(guard = "RequireRole(Role::Admin)")] + async fn create_user(&self, ctx: &Context<'_>, input: CreateUserInput) -> Result { + let user_service = ctx.data::()?; + user_service.create_user(input).await + } + + async fn login(&self, ctx: &Context<'_>, input: LoginInput) -> Result { + let user_service = ctx.data::()?; + user_service.login(input).await + } + + async fn create_invite_code( + &self, + ctx: &Context<'_>, + input: CreateInviteCodeInput, + ) -> Result { + let auth_user = get_auth_user(ctx).await?; + let invite_code_service = ctx.data::()?; + + let code = invite_code_service + .create_invite_code(auth_user.id, input) + .await?; + + // Get the invite code details to return expires_at + let invite_codes = invite_code_service + .get_invite_codes_by_creator(auth_user.id) + .await?; + let invite_code = invite_codes + .into_iter() + .find(|ic| ic.code == code) + .ok_or_else(|| async_graphql::Error::new("Failed to retrieve created invite code"))?; + + Ok(InviteCodeResponse { + code, + expires_at: invite_code.expires_at, + }) + } + + async fn initialize_admin( + &self, + ctx: &Context<'_>, + input: InitializeAdminInput, + ) -> Result { + let user_service = ctx.data::()?; + + match user_service + .initialize_admin(input.username, input.email, input.password) + .await + { + Ok(user) => Ok(InitializeAdminResponse { + success: true, + message: "Admin user initialized successfully".to_string(), + user: Some(user), + }), + Err(e) => Ok(InitializeAdminResponse { + success: false, + message: e.message, + user: None, + }), + } + } +} diff --git a/src/graphql/query.rs b/src/graphql/query.rs new file mode 100644 index 0000000..9392f3f --- /dev/null +++ b/src/graphql/query.rs @@ -0,0 +1,71 @@ +use crate::auth::get_auth_user; +use crate::graphql::guards::RequireRole; +use crate::graphql::types::UserInfoRespnose; +use crate::models::invite_code::InviteCode; +use crate::models::user::{Role, User}; +use crate::services::invite_code_service::InviteCodeService; +use crate::services::user_service::UserService; +use async_graphql::{Context, Object, Result}; +use tracing::info; + +pub struct QueryRoot; + +#[Object] +impl QueryRoot { + async fn health_check(&self) -> &str { + "OK" + } + + #[graphql(guard = "RequireRole(Role::User)")] + async fn current_user(&self, ctx: &Context<'_>) -> Result { + let auth_user = get_auth_user(ctx).await?; + let user_service = ctx.data::()?; + + user_service + .get_user_by_id(auth_user.id) + .await? + .ok_or_else(|| async_graphql::Error::new("User not found")) + } + + #[graphql(guard = "RequireRole(Role::Admin)")] + async fn secret_data(&self, _ctx: &Context<'_>) -> &str { + "This is super secret admin data!" + } + + #[graphql(guard = "RequireRole(Role::Admin)")] + async fn users( + &self, + ctx: &Context<'_>, + offset: Option, + limit: Option, + ) -> Result> { + let user_service = ctx.data::()?; + info!("users im here"); + let offset = offset.unwrap_or(0); + let limit = limit.unwrap_or(20); + user_service.get_all_users(offset, limit).await + } + + #[graphql(guard = "RequireRole(Role::User)")] + async fn my_invite_codes(&self, ctx: &Context<'_>) -> Result> { + let auth_user = get_auth_user(ctx).await?; + let invite_code_service = ctx.data::()?; + invite_code_service + .get_invite_codes_by_creator(auth_user.id) + .await + } + + #[graphql(guard = "RequireRole(Role::Admin)")] + async fn validate_invite_code(&self, ctx: &Context<'_>, code: String) -> Result { + let invite_code_service = ctx.data::()?; + invite_code_service + .validate_invite_code(crate::models::invite_code::ValidateInviteCodeInput { code }) + .await + } + + #[graphql(guard = "RequireRole(Role::Admin)")] + async fn users_info(&self, ctx: &Context<'_>) -> Result { + let user_service = ctx.data::()?; + user_service.users_info().await + } +} diff --git a/src/graphql/subscription.rs b/src/graphql/subscription.rs new file mode 100644 index 0000000..da7c8f0 --- /dev/null +++ b/src/graphql/subscription.rs @@ -0,0 +1,22 @@ +use async_graphql::{Subscription, Result}; +use futures_util::{Stream, StreamExt}; +use std::time::Duration; +use tokio::time::interval; + +pub struct SubscriptionRoot; + +#[Subscription] +impl SubscriptionRoot { + async fn ticks(&self) -> impl Stream { + let mut interval = interval(Duration::from_secs(1)); + let mut counter = 0; + + async_stream::stream! { + loop { + interval.tick().await; + counter += 1; + yield counter; + } + } + } +} \ No newline at end of file diff --git a/src/graphql/types.rs b/src/graphql/types.rs new file mode 100644 index 0000000..5202946 --- /dev/null +++ b/src/graphql/types.rs @@ -0,0 +1,70 @@ +use crate::models::user::Role; +use async_graphql::{InputObject, SimpleObject}; + +#[derive(InputObject)] +pub struct RegisterInput { + pub username: String, + pub email: String, + pub password: String, + pub invite_code: String, + pub role: Option, +} + +#[derive(InputObject)] +pub struct CreateUserInput { + pub username: String, + pub email: String, + pub password: String, + pub role: Option, +} + +#[derive(InputObject)] +pub struct LoginInput { + pub username: String, + pub password: String, +} + +#[derive(SimpleObject)] +pub struct LoginResponse { + pub token: String, + pub user_id: String, +} + +#[derive(InputObject)] +pub struct CreateInviteCodeInput { + pub expires_in_days: Option, +} + +#[derive(InputObject)] +pub struct ValidateInviteCodeInput { + pub code: String, +} + +#[derive(SimpleObject)] +pub struct InviteCodeResponse { + pub code: String, + pub expires_at: Option>, +} + +#[derive(InputObject)] +pub struct InitializeAdminInput { + pub username: String, + pub email: String, + pub password: String, +} + +#[derive(SimpleObject)] +pub struct InitializeAdminResponse { + pub success: bool, + pub message: String, + pub user: Option, +} + +#[derive(SimpleObject)] +pub struct UserInfoRespnose { + pub total_users: i64, + pub total_active_users: i64, + pub total_inactive_users: i64, + pub total_admin_users: i64, + pub total_user_users: i64, +} diff --git a/src/main.rs b/src/main.rs index cba842a..793f1aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,146 +1,36 @@ -use axum::{ - Router, - extract::{Path, Query}, - http::{StatusCode, header}, - response::{IntoResponse, Response}, - routing::get, -}; +mod app; +mod auth; +mod config; +mod db; +mod graphql; +mod models; +mod services; -use std::collections::HashMap; -use tokio::fs; -use tower_http::cors::{Any, CorsLayer}; +use app::create_router; +use config::Config; +use db::{create_pool, run_migrations}; #[tokio::main] -async fn main() { - // 初始化日志 +async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); - // 配置更精确的CORS - let cors = CorsLayer::new() - .allow_origin(Any) // 允许所有来源,也可以指定特定域名 - .allow_methods([axum::http::Method::GET]) // 只允许GET请求 - .allow_headers([axum::http::header::CONTENT_TYPE]); // 允许的头部 + let config = Config::from_env()?; + let pool = create_pool(&config.database_url).await?; - // 构建应用路由 - let app = Router::new() - .route("/", get(root)) - .route("/tiles/{z}/{x}/{y}", get(get_tile)) - .route("/test", get(get_test)) - .layer(cors); // 使用配置好的CORS + run_migrations(&pool).await?; - // 启动服务器,监听端口 3050 - let listener = tokio::net::TcpListener::bind("0.0.0.0:3050").await.unwrap(); - println!("瓦片服务器启动成功,监听地址: http://0.0.0.0:3050"); - println!("API 示例: GET /tiles/6/42/20.png?time=202507220006"); + let router = create_router(pool, config.clone()); - axum::serve(listener, app).await.unwrap(); -} - -// 根路径处理器 -async fn root() -> &'static str { - "瓦片服务器运行中!\n\n使用方式:\nGET /tiles/{z}/{x}/{y}.png?time=YYYYMMDDHHMM\n\n示例:\nGET /tiles/6/42/20.png?time=202507220006" -} - -// 瓦片处理器 -async fn get_tile( - Path((z, x, y)): Path<(String, String, String)>, - Query(params): Query>, -) -> Result { - // 解析时间参数 - let time = params.get("time").ok_or(TileError::MissingTimeParameter)?; - - // 验证时间格式(YYYYMMDDHHMM,12位数字) - if time.len() != 12 || !time.chars().all(|c| c.is_ascii_digit()) { - return Err(TileError::InvalidTimeFormat); - } - - // 构建文件路径 - let file_path = format!("tiles/{}/{}/{}/{}.png", time, z, x, y); - - // 异步读取文件 - match fs::read(&file_path).await { - Ok(file_data) => { - // 创建响应,设置正确的 Content-Type 和缓存头 - let response = Response::builder() - .status(StatusCode::OK) - .header(header::CONTENT_TYPE, "image/png") - .header(header::CACHE_CONTROL, "public, max-age=3600") // 缓存1小时 - .header(header::ETAG, format!("\"{}\"", generate_etag(&file_path))) - .body(file_data.into()) - .map_err(|_| TileError::InternalServerError)?; - - Ok(response) - } - Err(_) => { - tracing::warn!("瓦片文件不存在: {}", file_path); - Err(TileError::TileNotFound) - } - } -} - -// 瓦片处理器 -async fn get_test() -> Result { - // 异步读取文件 - match fs::read("/Users/xiang.li1/projects/radarprocess/china.png").await { - Ok(file_data) => { - // 创建响应,设置正确的 Content-Type 和缓存头 - let response = Response::builder() - .status(StatusCode::OK) - .header(header::CONTENT_TYPE, "image/png") - .header(header::CACHE_CONTROL, "public, max-age=3600") // 缓存1小时 - .header( - header::ETAG, - format!( - "\"{}\"", - generate_etag("/Users/xiang.li1/projects/radarprocess/china.png") - ), - ) - .body(file_data.into()) - .map_err(|_| TileError::InternalServerError)?; - - Ok(response) - } - Err(_) => Err(TileError::TileNotFound), - } -} - -// 生成简单的 ETag -fn generate_etag(path: &str) -> String { - use std::collections::hash_map::DefaultHasher; - use std::hash::{Hash, Hasher}; - - let mut hasher = DefaultHasher::new(); - path.hash(&mut hasher); - format!("{:x}", hasher.finish()) -} - -// 错误类型定义 -#[derive(Debug)] -enum TileError { - MissingTimeParameter, - InvalidTimeFormat, - TileNotFound, - InternalServerError, -} - -// 错误响应实现 -impl IntoResponse for TileError { - fn into_response(self) -> Response { - let (status, error_message) = match self { - TileError::MissingTimeParameter => ( - StatusCode::BAD_REQUEST, - "缺少时间参数。请使用 ?time=YYYYMMDDHHMM 格式", - ), - TileError::InvalidTimeFormat => ( - StatusCode::BAD_REQUEST, - "时间格式无效。请使用 YYYYMMDDHHMM 格式(12位数字)", - ), - TileError::TileNotFound => (StatusCode::NOT_FOUND, "瓦片文件不存在"), - TileError::InternalServerError => (StatusCode::INTERNAL_SERVER_ERROR, "服务器内部错误"), - }; - - tracing::error!("瓦片服务错误: {:?}", self); - - (status, error_message).into_response() - } + let listener = tokio::net::TcpListener::bind(&format!("0.0.0.0:{}", config.port)).await?; + + tracing::info!("GraphQL server running on http://0.0.0.0:{}", config.port); + tracing::info!( + "GraphiQL playground: http://0.0.0.0:{}/graphql", + config.port + ); + tracing::info!("WebSocket subscriptions: ws://0.0.0.0:{}/ws", config.port); + + axum::serve(listener, router).await?; + + Ok(()) } diff --git a/src/models/invite_code.rs b/src/models/invite_code.rs new file mode 100644 index 0000000..4cb97b2 --- /dev/null +++ b/src/models/invite_code.rs @@ -0,0 +1,27 @@ +use async_graphql::SimpleObject; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use sqlx::FromRow; +use uuid::Uuid; + +#[derive(Debug, Clone, FromRow, SimpleObject)] +pub struct InviteCode { + pub id: Uuid, + pub code: String, + pub created_by: Uuid, + pub used_by: Option, + pub is_used: bool, + pub expires_at: Option>, + pub created_at: Option>, + pub used_at: Option>, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct UseInviteCodeInput { + pub code: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct ValidateInviteCodeInput { + pub code: String, +} diff --git a/src/models/mod.rs b/src/models/mod.rs new file mode 100644 index 0000000..f30c7d6 --- /dev/null +++ b/src/models/mod.rs @@ -0,0 +1,5 @@ +pub mod invite_code; +pub mod user; + +pub use invite_code::*; +pub use user::*; diff --git a/src/models/user.rs b/src/models/user.rs new file mode 100644 index 0000000..b944971 --- /dev/null +++ b/src/models/user.rs @@ -0,0 +1,47 @@ +use async_graphql::{Enum, SimpleObject}; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use sqlx::FromRow; +use uuid::Uuid; + +#[derive(Debug, Clone, Serialize, Deserialize, Enum, Copy, PartialEq, Eq, sqlx::Type)] +#[sqlx(type_name = "VARCHAR", rename_all = "PascalCase")] +pub enum Role { + User, + Admin, +} + +impl Default for Role { + fn default() -> Self { + Role::User + } +} + +#[derive(Debug, Clone, FromRow, SimpleObject)] +pub struct User { + pub id: Uuid, + pub username: String, + pub email: String, + #[graphql(skip)] + pub password_hash: String, + pub role: Role, + pub invite_code_id: Option, + pub is_activate: bool, + pub created_at: Option>, + pub updated_at: Option>, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct CreateUserInput { + pub username: String, + pub email: String, + pub password: String, + pub invite_code: String, + pub role: Option, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct LoginInput { + pub username: String, + pub password: String, +} diff --git a/src/services/invite_code_service.rs b/src/services/invite_code_service.rs new file mode 100644 index 0000000..49001dd --- /dev/null +++ b/src/services/invite_code_service.rs @@ -0,0 +1,130 @@ +use async_graphql::{Error, Result}; +use chrono::Utc; +use sqlx::PgPool; +use uuid::Uuid; + +use crate::{ + graphql::types::CreateInviteCodeInput, + models::invite_code::{InviteCode, UseInviteCodeInput, ValidateInviteCodeInput}, +}; + +pub struct InviteCodeService { + pool: PgPool, +} + +impl InviteCodeService { + pub fn new(pool: PgPool) -> Self { + Self { pool } + } + + pub async fn create_invite_code( + &self, + creator_id: Uuid, + input: CreateInviteCodeInput, + ) -> Result { + let expires_in_days = input.expires_in_days.unwrap_or(30); + + let code = sqlx::query_scalar!( + "SELECT create_invite_code($1, $2)", + creator_id, + expires_in_days + ) + .fetch_one(&self.pool) + .await + .map_err(|e| Error::new(format!("Failed to create invite code: {}", e)))? + .unwrap(); + + Ok(code) + } + + pub async fn validate_invite_code(&self, input: ValidateInviteCodeInput) -> Result { + let invite_code = sqlx::query_as!( + InviteCode, + r#" + SELECT id, code, created_by, used_by, is_used, expires_at, created_at, used_at + FROM invite_codes + WHERE code = $1 + "#, + input.code + ) + .fetch_optional(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))? + .ok_or_else(|| Error::new("Invalid invite code"))?; + + // Check if code is already used + if invite_code.is_used { + return Err(Error::new("Invite code has already been used")); + } + + // Check if code has expired + if let Some(expires_at) = invite_code.expires_at { + if expires_at < Utc::now() { + return Err(Error::new("Invite code has expired")); + } + } + + Ok(true) + } + + pub async fn use_invite_code(&self, code: &str, user_id: Uuid) -> Result { + // First validate the code + self.validate_invite_code(ValidateInviteCodeInput { + code: code.to_string(), + }) + .await?; + + // Use the code in a transaction + let invite_code_id = sqlx::query_scalar!( + r#" + UPDATE invite_codes + SET is_used = true, used_by = $1, used_at = NOW() + WHERE code = $2 AND is_used = false + RETURNING id + "#, + user_id, + code + ) + .fetch_optional(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))? + .ok_or_else(|| Error::new("Failed to use invite code"))?; + + Ok(invite_code_id) + } + + pub async fn get_invite_codes_by_creator(&self, creator_id: Uuid) -> Result> { + let invite_codes = sqlx::query_as!( + InviteCode, + r#" + SELECT id, code, created_by, used_by, is_used, expires_at, created_at, used_at + FROM invite_codes + WHERE created_by = $1 + ORDER BY created_at DESC + "#, + creator_id + ) + .fetch_all(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + Ok(invite_codes) + } + + pub async fn get_invite_code_by_id(&self, id: Uuid) -> Result> { + let invite_code = sqlx::query_as!( + InviteCode, + r#" + SELECT id, code, created_by, used_by, is_used, expires_at, created_at, used_at + FROM invite_codes + WHERE id = $1 + "#, + id + ) + .fetch_optional(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + Ok(invite_code) + } +} diff --git a/src/services/mod.rs b/src/services/mod.rs new file mode 100644 index 0000000..8457045 --- /dev/null +++ b/src/services/mod.rs @@ -0,0 +1,3 @@ +pub mod invite_code_service; +pub mod system_config_service; +pub mod user_service; diff --git a/src/services/system_config_service.rs b/src/services/system_config_service.rs new file mode 100644 index 0000000..112335b --- /dev/null +++ b/src/services/system_config_service.rs @@ -0,0 +1,80 @@ +use async_graphql::{Error, Result}; +use sqlx::PgPool; +use tracing::info; + +pub struct SystemConfigService { + pool: PgPool, +} + +impl SystemConfigService { + pub fn new(pool: PgPool) -> Self { + Self { pool } + } + + pub async fn is_admin_initialized(&self) -> Result { + let value = sqlx::query_scalar!( + r#" + SELECT value FROM system_config WHERE key = 'admin_initialized' + "# + ) + .fetch_optional(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))? + .unwrap_or_else(|| "false".to_string()); + + Ok(value == "true") + } + + pub async fn set_admin_initialized(&self) -> Result<()> { + sqlx::query!( + r#" + UPDATE system_config + SET value = 'true', updated_at = NOW() + WHERE key = 'admin_initialized' + "# + ) + .execute(&self.pool) + .await + .map_err(|e| { + Error::new(format!( + "Failed to update admin initialization status: {}", + e + )) + })?; + + info!("Admin initialization status set to true"); + Ok(()) + } + + pub async fn get_config_value(&self, key: &str) -> Result> { + let value = sqlx::query_scalar!( + r#" + SELECT value FROM system_config WHERE key = $1 + "#, + key + ) + .fetch_optional(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + Ok(value) + } + + pub async fn set_config_value(&self, key: &str, value: &str) -> Result<()> { + sqlx::query!( + r#" + INSERT INTO system_config (key, value) + VALUES ($1, $2) + ON CONFLICT (key) + DO UPDATE SET value = $2, updated_at = NOW() + "#, + key, + value + ) + .execute(&self.pool) + .await + .map_err(|e| Error::new(format!("Failed to set config value: {}", e)))?; + + Ok(()) + } +} diff --git a/src/services/user_service.rs b/src/services/user_service.rs new file mode 100644 index 0000000..ca90838 --- /dev/null +++ b/src/services/user_service.rs @@ -0,0 +1,338 @@ +use argon2::password_hash::{rand_core::OsRng, SaltString}; +use argon2::{Argon2, PasswordHash, PasswordHasher, PasswordVerifier}; +use async_graphql::{Error, Result}; +use sqlx::PgPool; +use tracing::info; +use uuid::Uuid; + +use crate::auth::Claims; +use crate::graphql::types::{ + CreateUserInput, LoginInput, LoginResponse, RegisterInput, UserInfoRespnose, +}; +use crate::models::user::{Role, User}; +use crate::services::invite_code_service::InviteCodeService; +use crate::services::system_config_service::SystemConfigService; + +pub struct UserService { + pool: PgPool, + jwt_secret: String, +} + +impl UserService { + pub fn new(pool: PgPool, jwt_secret: String) -> Self { + Self { pool, jwt_secret } + } + + pub async fn register(&self, input: RegisterInput) -> Result { + let password_hash = self.hash_password(&input.password)?; + let role = input.role.unwrap_or(Role::User); + + // Use transaction to ensure data consistency + let mut tx = self + .pool + .begin() + .await + .map_err(|e| Error::new(format!("Failed to start transaction: {}", e)))?; + + // Validate invite code first + let invite_code_service = InviteCodeService::new(self.pool.clone()); + invite_code_service + .validate_invite_code(crate::models::invite_code::ValidateInviteCodeInput { + code: input.invite_code.clone(), + }) + .await?; + + // Create user first + let user = sqlx::query_as!( + User, + r#" + INSERT INTO users (username, email, password_hash, role, is_activate) + VALUES ($1, $2, $3, $4, $5) + RETURNING id, username, email, password_hash, role as "role: Role", invite_code_id, is_activate, created_at, updated_at + "#, + input.username, + input.email, + password_hash, + role as Role, + true + ) + .fetch_one(&mut *tx) + .await + .map_err(|e| { + if e.to_string().contains("duplicate key") { + Error::new("Username or email already exists") + } else { + Error::new(format!("Failed to create user: {}", e)) + } + })?; + + // Use the invite code + let invite_code_id = sqlx::query_scalar!( + r#" + UPDATE invite_codes + SET is_used = true, used_by = $1, used_at = NOW() + WHERE code = $2 AND is_used = false + RETURNING id + "#, + user.id, + input.invite_code + ) + .fetch_optional(&mut *tx) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))? + .ok_or_else(|| Error::new("Failed to use invite code"))?; + + // Update user with invite code id + let user = sqlx::query_as!( + User, + r#" + UPDATE users SET invite_code_id = $1 WHERE id = $2 + RETURNING id, username, email, password_hash, role as "role: Role", invite_code_id, is_activate, created_at, updated_at + "#, + invite_code_id, + user.id + ) + .fetch_one(&mut *tx) + .await + .map_err(|e| Error::new(format!("Failed to update user with invite code: {}", e)))?; + + // Commit transaction + tx.commit() + .await + .map_err(|e| Error::new(format!("Failed to commit transaction: {}", e)))?; + + Ok(user) + } + + pub async fn create_user(&self, input: CreateUserInput) -> Result { + let password_hash = self.hash_password(&input.password)?; + let role = input.role.unwrap_or(Role::User); + + // Create user first + let user = sqlx::query_as!( + User, + r#" + INSERT INTO users (username, email, password_hash, role, is_activate) + VALUES ($1, $2, $3, $4, $5) + RETURNING id, username, email, password_hash, role as "role: Role", invite_code_id, is_activate, created_at, updated_at + "#, + input.username, + input.email, + password_hash, + role as Role, + true + ) + .fetch_one(&self.pool) + .await + .map_err(|e| { + if e.to_string().contains("duplicate key") { + Error::new("Username or email already exists") + } else { + Error::new(format!("Failed to create user: {}", e)) + } + })?; + + Ok(user) + } + + pub async fn login(&self, input: LoginInput) -> Result { + let user = sqlx::query_as!( + User, + r#" + SELECT id, username, email, password_hash, role as "role: Role", invite_code_id, is_activate, created_at, updated_at + FROM users WHERE username = $1 + "#, + input.username + ) + .fetch_optional(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))? + .ok_or_else(|| Error::new("Invalid credentials"))?; + + if !self.verify_password(&input.password, &user.password_hash)? { + return Err(Error::new("Invalid credentials")); + } + + let token = Claims::new(&user, &self.jwt_secret)?; + + Ok(LoginResponse { + token, + user_id: user.id.to_string(), + }) + } + + pub async fn get_user_by_id(&self, id: Uuid) -> Result> { + let user = sqlx::query_as!( + User, + r#" + SELECT id, username, email, password_hash, role as "role: Role", invite_code_id, is_activate, created_at, updated_at + FROM users WHERE id = $1 + "#, + id + ) + .fetch_optional(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + Ok(user) + } + + pub async fn get_all_users(&self, offset: i64, limit: i64) -> Result> { + let users = sqlx::query_as!( + User, + r#"SELECT id, username, email, password_hash, role as "role: Role", invite_code_id, is_activate, created_at, updated_at FROM users LIMIT $1 OFFSET $2"#, + limit, + offset + ) + .fetch_all(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + info!("users: {:?}", users); + + Ok(users) + } + + pub async fn initialize_admin( + &self, + username: String, + email: String, + password: String, + ) -> Result { + // Check if admin is already initialized + let system_config_service = SystemConfigService::new(self.pool.clone()); + if system_config_service.is_admin_initialized().await? { + return Err(Error::new("Admin has already been initialized")); + } + + // Check if any users exist + let user_count = sqlx::query_scalar!(r#"SELECT COUNT(*) FROM users"#) + .fetch_one(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + if user_count.unwrap_or(0) > 0 { + return Err(Error::new("Users already exist in the system")); + } + + let password_hash = self.hash_password(&password)?; + + // Use transaction to ensure data consistency + let mut tx = self + .pool + .begin() + .await + .map_err(|e| Error::new(format!("Failed to start transaction: {}", e)))?; + + // Create admin user + let user = sqlx::query_as!( + User, + r#" + INSERT INTO users (username, email, password_hash, role, is_activate) + VALUES ($1, $2, $3, $4, $5) + RETURNING id, username, email, password_hash, role as "role: Role", invite_code_id, is_activate, created_at, updated_at + "#, + username, + email, + password_hash, + Role::Admin as Role, + true + ) + .fetch_one(&mut *tx) + .await + .map_err(|e| { + if e.to_string().contains("duplicate key") { + Error::new("Username or email already exists") + } else { + Error::new(format!("Failed to create admin user: {}", e)) + } + })?; + + // Mark admin as initialized + system_config_service.set_admin_initialized().await?; + + // Commit transaction + tx.commit() + .await + .map_err(|e| Error::new(format!("Failed to commit transaction: {}", e)))?; + + info!("Admin user initialized: {}", user.username); + Ok(user) + } + + fn hash_password(&self, password: &str) -> Result { + let salt = SaltString::generate(&mut OsRng); + let argon2 = Argon2::default(); + + argon2 + .hash_password(password.as_bytes(), &salt) + .map_err(|e| Error::new(format!("Failed to hash password: {}", e)))? + .to_string() + .pipe(Ok) + } + + fn verify_password(&self, password: &str, hash: &str) -> Result { + let parsed_hash = PasswordHash::new(hash) + .map_err(|e| Error::new(format!("Invalid password hash: {}", e)))?; + + let argon2 = Argon2::default(); + Ok(argon2 + .verify_password(password.as_bytes(), &parsed_hash) + .is_ok()) + } + + pub async fn users_info(&self) -> Result { + let total_users = sqlx::query_scalar!(r#"SELECT COUNT(*) FROM users"#) + .fetch_one(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + let total_active_users = + sqlx::query_scalar!(r#"SELECT COUNT(*) FROM users WHERE is_activate = true"#) + .fetch_one(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + let total_inactive_users = + sqlx::query_scalar!(r#"SELECT COUNT(*) FROM users WHERE is_activate = false"#) + .fetch_one(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + let total_admin_users = + sqlx::query_scalar!(r#"SELECT COUNT(*) FROM users WHERE role = 'admin'"#) + .fetch_one(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + let total_user_users = + sqlx::query_scalar!(r#"SELECT COUNT(*) FROM users WHERE role = 'user'"#) + .fetch_one(&self.pool) + .await + .map_err(|e| Error::new(format!("Database error: {}", e)))?; + + Ok(UserInfoRespnose { + total_users: total_users.unwrap_or(0), + total_active_users: total_active_users.unwrap_or(0), + total_inactive_users: total_inactive_users.unwrap_or(0), + total_admin_users: total_admin_users.unwrap_or(0), + total_user_users: total_user_users.unwrap_or(0), + }) + } +} + +trait Pipe { + fn pipe(self, f: F) -> R + where + F: FnOnce(Self) -> R, + Self: Sized; +} + +impl Pipe for T { + fn pipe(self, f: F) -> R + where + F: FnOnce(Self) -> R, + { + f(self) + } +}