diff options
author | FxQnLr <[email protected]> | 2023-10-21 21:31:02 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2023-10-21 21:31:02 +0200 |
commit | e8a8b2d33eec5da6701b04181b14de755e8b8063 (patch) | |
tree | 5cd77421900fd8ec02f05d15e6fb195f28dfceb4 | |
parent | 48943e0de28b99d7f108e96b7d250bbf1a6c5a5b (diff) | |
parent | bf1aeb7191bfaa75f1acf47c675bc68b9fac1cd8 (diff) | |
download | webol-e8a8b2d33eec5da6701b04181b14de755e8b8063.tar webol-e8a8b2d33eec5da6701b04181b14de755e8b8063.tar.gz webol-e8a8b2d33eec5da6701b04181b14de755e8b8063.zip |
Merge pull request #4 from FxQnLr/database-init
int db in process
-rw-r--r-- | Cargo.lock | 144 | ||||
-rw-r--r-- | docker-compose.yml | 3 | ||||
-rw-r--r-- | migrations/20231009123228_devices.sql | 4 | ||||
-rw-r--r-- | src/auth.rs | 3 | ||||
-rw-r--r-- | src/db.rs | 26 | ||||
-rw-r--r-- | src/error.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 25 |
7 files changed, 116 insertions, 90 deletions
@@ -42,9 +42,9 @@ dependencies = [ | |||
42 | 42 | ||
43 | [[package]] | 43 | [[package]] |
44 | name = "aho-corasick" | 44 | name = "aho-corasick" |
45 | version = "1.1.1" | 45 | version = "1.1.2" |
46 | source = "registry+https://github.com/rust-lang/crates.io-index" | 46 | source = "registry+https://github.com/rust-lang/crates.io-index" |
47 | checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" | 47 | checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" |
48 | dependencies = [ | 48 | dependencies = [ |
49 | "memchr", | 49 | "memchr", |
50 | ] | 50 | ] |
@@ -57,9 +57,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" | |||
57 | 57 | ||
58 | [[package]] | 58 | [[package]] |
59 | name = "async-trait" | 59 | name = "async-trait" |
60 | version = "0.1.73" | 60 | version = "0.1.74" |
61 | source = "registry+https://github.com/rust-lang/crates.io-index" | 61 | source = "registry+https://github.com/rust-lang/crates.io-index" |
62 | checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" | 62 | checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" |
63 | dependencies = [ | 63 | dependencies = [ |
64 | "proc-macro2", | 64 | "proc-macro2", |
65 | "quote", | 65 | "quote", |
@@ -172,9 +172,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" | |||
172 | 172 | ||
173 | [[package]] | 173 | [[package]] |
174 | name = "bitflags" | 174 | name = "bitflags" |
175 | version = "2.4.0" | 175 | version = "2.4.1" |
176 | source = "registry+https://github.com/rust-lang/crates.io-index" | 176 | source = "registry+https://github.com/rust-lang/crates.io-index" |
177 | checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" | 177 | checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" |
178 | dependencies = [ | 178 | dependencies = [ |
179 | "serde", | 179 | "serde", |
180 | ] | 180 | ] |
@@ -242,9 +242,9 @@ checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" | |||
242 | 242 | ||
243 | [[package]] | 243 | [[package]] |
244 | name = "cpufeatures" | 244 | name = "cpufeatures" |
245 | version = "0.2.9" | 245 | version = "0.2.10" |
246 | source = "registry+https://github.com/rust-lang/crates.io-index" | 246 | source = "registry+https://github.com/rust-lang/crates.io-index" |
247 | checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" | 247 | checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" |
248 | dependencies = [ | 248 | dependencies = [ |
249 | "libc", | 249 | "libc", |
250 | ] | 250 | ] |
@@ -306,9 +306,12 @@ dependencies = [ | |||
306 | 306 | ||
307 | [[package]] | 307 | [[package]] |
308 | name = "deranged" | 308 | name = "deranged" |
309 | version = "0.3.8" | 309 | version = "0.3.9" |
310 | source = "registry+https://github.com/rust-lang/crates.io-index" | 310 | source = "registry+https://github.com/rust-lang/crates.io-index" |
311 | checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" | 311 | checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" |
312 | dependencies = [ | ||
313 | "powerfmt", | ||
314 | ] | ||
312 | 315 | ||
313 | [[package]] | 316 | [[package]] |
314 | name = "digest" | 317 | name = "digest" |
@@ -524,9 +527,9 @@ dependencies = [ | |||
524 | 527 | ||
525 | [[package]] | 528 | [[package]] |
526 | name = "hashbrown" | 529 | name = "hashbrown" |
527 | version = "0.14.1" | 530 | version = "0.14.2" |
528 | source = "registry+https://github.com/rust-lang/crates.io-index" | 531 | source = "registry+https://github.com/rust-lang/crates.io-index" |
529 | checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" | 532 | checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" |
530 | dependencies = [ | 533 | dependencies = [ |
531 | "ahash 0.8.3", | 534 | "ahash 0.8.3", |
532 | "allocator-api2", | 535 | "allocator-api2", |
@@ -538,7 +541,7 @@ version = "0.8.4" | |||
538 | source = "registry+https://github.com/rust-lang/crates.io-index" | 541 | source = "registry+https://github.com/rust-lang/crates.io-index" |
539 | checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" | 542 | checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" |
540 | dependencies = [ | 543 | dependencies = [ |
541 | "hashbrown 0.14.1", | 544 | "hashbrown 0.14.2", |
542 | ] | 545 | ] |
543 | 546 | ||
544 | [[package]] | 547 | [[package]] |
@@ -663,7 +666,7 @@ dependencies = [ | |||
663 | "httpdate", | 666 | "httpdate", |
664 | "itoa", | 667 | "itoa", |
665 | "pin-project-lite", | 668 | "pin-project-lite", |
666 | "socket2 0.4.9", | 669 | "socket2 0.4.10", |
667 | "tokio", | 670 | "tokio", |
668 | "tower-service", | 671 | "tower-service", |
669 | "tracing", | 672 | "tracing", |
@@ -687,7 +690,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
687 | checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" | 690 | checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" |
688 | dependencies = [ | 691 | dependencies = [ |
689 | "equivalent", | 692 | "equivalent", |
690 | "hashbrown 0.14.1", | 693 | "hashbrown 0.14.2", |
691 | ] | 694 | ] |
692 | 695 | ||
693 | [[package]] | 696 | [[package]] |
@@ -762,9 +765,9 @@ checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" | |||
762 | 765 | ||
763 | [[package]] | 766 | [[package]] |
764 | name = "lock_api" | 767 | name = "lock_api" |
765 | version = "0.4.10" | 768 | version = "0.4.11" |
766 | source = "registry+https://github.com/rust-lang/crates.io-index" | 769 | source = "registry+https://github.com/rust-lang/crates.io-index" |
767 | checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" | 770 | checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" |
768 | dependencies = [ | 771 | dependencies = [ |
769 | "autocfg", | 772 | "autocfg", |
770 | "scopeguard", | 773 | "scopeguard", |
@@ -969,13 +972,13 @@ dependencies = [ | |||
969 | 972 | ||
970 | [[package]] | 973 | [[package]] |
971 | name = "parking_lot_core" | 974 | name = "parking_lot_core" |
972 | version = "0.9.8" | 975 | version = "0.9.9" |
973 | source = "registry+https://github.com/rust-lang/crates.io-index" | 976 | source = "registry+https://github.com/rust-lang/crates.io-index" |
974 | checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" | 977 | checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" |
975 | dependencies = [ | 978 | dependencies = [ |
976 | "cfg-if", | 979 | "cfg-if", |
977 | "libc", | 980 | "libc", |
978 | "redox_syscall", | 981 | "redox_syscall 0.4.1", |
979 | "smallvec", | 982 | "smallvec", |
980 | "windows-targets", | 983 | "windows-targets", |
981 | ] | 984 | ] |
@@ -1112,6 +1115,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1112 | checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" | 1115 | checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" |
1113 | 1116 | ||
1114 | [[package]] | 1117 | [[package]] |
1118 | name = "powerfmt" | ||
1119 | version = "0.2.0" | ||
1120 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1121 | checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" | ||
1122 | |||
1123 | [[package]] | ||
1115 | name = "ppv-lite86" | 1124 | name = "ppv-lite86" |
1116 | version = "0.2.17" | 1125 | version = "0.2.17" |
1117 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1126 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1119,9 +1128,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" | |||
1119 | 1128 | ||
1120 | [[package]] | 1129 | [[package]] |
1121 | name = "proc-macro2" | 1130 | name = "proc-macro2" |
1122 | version = "1.0.68" | 1131 | version = "1.0.69" |
1123 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1132 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1124 | checksum = "5b1106fec09662ec6dd98ccac0f81cef56984d0b49f75c92d8cbad76e20c005c" | 1133 | checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" |
1125 | dependencies = [ | 1134 | dependencies = [ |
1126 | "unicode-ident", | 1135 | "unicode-ident", |
1127 | ] | 1136 | ] |
@@ -1175,15 +1184,24 @@ dependencies = [ | |||
1175 | ] | 1184 | ] |
1176 | 1185 | ||
1177 | [[package]] | 1186 | [[package]] |
1187 | name = "redox_syscall" | ||
1188 | version = "0.4.1" | ||
1189 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1190 | checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" | ||
1191 | dependencies = [ | ||
1192 | "bitflags 1.3.2", | ||
1193 | ] | ||
1194 | |||
1195 | [[package]] | ||
1178 | name = "regex" | 1196 | name = "regex" |
1179 | version = "1.9.6" | 1197 | version = "1.10.2" |
1180 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1198 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1181 | checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" | 1199 | checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" |
1182 | dependencies = [ | 1200 | dependencies = [ |
1183 | "aho-corasick", | 1201 | "aho-corasick", |
1184 | "memchr", | 1202 | "memchr", |
1185 | "regex-automata 0.3.9", | 1203 | "regex-automata 0.4.3", |
1186 | "regex-syntax 0.7.5", | 1204 | "regex-syntax 0.8.2", |
1187 | ] | 1205 | ] |
1188 | 1206 | ||
1189 | [[package]] | 1207 | [[package]] |
@@ -1197,13 +1215,13 @@ dependencies = [ | |||
1197 | 1215 | ||
1198 | [[package]] | 1216 | [[package]] |
1199 | name = "regex-automata" | 1217 | name = "regex-automata" |
1200 | version = "0.3.9" | 1218 | version = "0.4.3" |
1201 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1219 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1202 | checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" | 1220 | checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" |
1203 | dependencies = [ | 1221 | dependencies = [ |
1204 | "aho-corasick", | 1222 | "aho-corasick", |
1205 | "memchr", | 1223 | "memchr", |
1206 | "regex-syntax 0.7.5", | 1224 | "regex-syntax 0.8.2", |
1207 | ] | 1225 | ] |
1208 | 1226 | ||
1209 | [[package]] | 1227 | [[package]] |
@@ -1214,9 +1232,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" | |||
1214 | 1232 | ||
1215 | [[package]] | 1233 | [[package]] |
1216 | name = "regex-syntax" | 1234 | name = "regex-syntax" |
1217 | version = "0.7.5" | 1235 | version = "0.8.2" |
1218 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1236 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1219 | checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" | 1237 | checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" |
1220 | 1238 | ||
1221 | [[package]] | 1239 | [[package]] |
1222 | name = "ron" | 1240 | name = "ron" |
@@ -1269,11 +1287,11 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" | |||
1269 | 1287 | ||
1270 | [[package]] | 1288 | [[package]] |
1271 | name = "rustix" | 1289 | name = "rustix" |
1272 | version = "0.38.18" | 1290 | version = "0.38.20" |
1273 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1291 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1274 | checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" | 1292 | checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" |
1275 | dependencies = [ | 1293 | dependencies = [ |
1276 | "bitflags 2.4.0", | 1294 | "bitflags 2.4.1", |
1277 | "errno", | 1295 | "errno", |
1278 | "libc", | 1296 | "libc", |
1279 | "linux-raw-sys", | 1297 | "linux-raw-sys", |
@@ -1300,18 +1318,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" | |||
1300 | 1318 | ||
1301 | [[package]] | 1319 | [[package]] |
1302 | name = "serde" | 1320 | name = "serde" |
1303 | version = "1.0.188" | 1321 | version = "1.0.189" |
1304 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1322 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1305 | checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" | 1323 | checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" |
1306 | dependencies = [ | 1324 | dependencies = [ |
1307 | "serde_derive", | 1325 | "serde_derive", |
1308 | ] | 1326 | ] |
1309 | 1327 | ||
1310 | [[package]] | 1328 | [[package]] |
1311 | name = "serde_derive" | 1329 | name = "serde_derive" |
1312 | version = "1.0.188" | 1330 | version = "1.0.189" |
1313 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1331 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1314 | checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" | 1332 | checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" |
1315 | dependencies = [ | 1333 | dependencies = [ |
1316 | "proc-macro2", | 1334 | "proc-macro2", |
1317 | "quote", | 1335 | "quote", |
@@ -1353,9 +1371,9 @@ dependencies = [ | |||
1353 | 1371 | ||
1354 | [[package]] | 1372 | [[package]] |
1355 | name = "sha1" | 1373 | name = "sha1" |
1356 | version = "0.10.5" | 1374 | version = "0.10.6" |
1357 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1375 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1358 | checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" | 1376 | checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" |
1359 | dependencies = [ | 1377 | dependencies = [ |
1360 | "cfg-if", | 1378 | "cfg-if", |
1361 | "cpufeatures", | 1379 | "cpufeatures", |
@@ -1409,9 +1427,9 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" | |||
1409 | 1427 | ||
1410 | [[package]] | 1428 | [[package]] |
1411 | name = "socket2" | 1429 | name = "socket2" |
1412 | version = "0.4.9" | 1430 | version = "0.4.10" |
1413 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1431 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1414 | checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" | 1432 | checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" |
1415 | dependencies = [ | 1433 | dependencies = [ |
1416 | "libc", | 1434 | "libc", |
1417 | "winapi", | 1435 | "winapi", |
@@ -1419,9 +1437,9 @@ dependencies = [ | |||
1419 | 1437 | ||
1420 | [[package]] | 1438 | [[package]] |
1421 | name = "socket2" | 1439 | name = "socket2" |
1422 | version = "0.5.4" | 1440 | version = "0.5.5" |
1423 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1441 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1424 | checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" | 1442 | checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" |
1425 | dependencies = [ | 1443 | dependencies = [ |
1426 | "libc", | 1444 | "libc", |
1427 | "windows-sys", | 1445 | "windows-sys", |
@@ -1563,7 +1581,7 @@ checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" | |||
1563 | dependencies = [ | 1581 | dependencies = [ |
1564 | "atoi", | 1582 | "atoi", |
1565 | "base64 0.21.4", | 1583 | "base64 0.21.4", |
1566 | "bitflags 2.4.0", | 1584 | "bitflags 2.4.1", |
1567 | "byteorder", | 1585 | "byteorder", |
1568 | "bytes", | 1586 | "bytes", |
1569 | "crc", | 1587 | "crc", |
@@ -1605,7 +1623,7 @@ checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" | |||
1605 | dependencies = [ | 1623 | dependencies = [ |
1606 | "atoi", | 1624 | "atoi", |
1607 | "base64 0.21.4", | 1625 | "base64 0.21.4", |
1608 | "bitflags 2.4.0", | 1626 | "bitflags 2.4.1", |
1609 | "byteorder", | 1627 | "byteorder", |
1610 | "crc", | 1628 | "crc", |
1611 | "dotenvy", | 1629 | "dotenvy", |
@@ -1711,25 +1729,25 @@ checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" | |||
1711 | dependencies = [ | 1729 | dependencies = [ |
1712 | "cfg-if", | 1730 | "cfg-if", |
1713 | "fastrand", | 1731 | "fastrand", |
1714 | "redox_syscall", | 1732 | "redox_syscall 0.3.5", |
1715 | "rustix", | 1733 | "rustix", |
1716 | "windows-sys", | 1734 | "windows-sys", |
1717 | ] | 1735 | ] |
1718 | 1736 | ||
1719 | [[package]] | 1737 | [[package]] |
1720 | name = "thiserror" | 1738 | name = "thiserror" |
1721 | version = "1.0.49" | 1739 | version = "1.0.50" |
1722 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1740 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1723 | checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" | 1741 | checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" |
1724 | dependencies = [ | 1742 | dependencies = [ |
1725 | "thiserror-impl", | 1743 | "thiserror-impl", |
1726 | ] | 1744 | ] |
1727 | 1745 | ||
1728 | [[package]] | 1746 | [[package]] |
1729 | name = "thiserror-impl" | 1747 | name = "thiserror-impl" |
1730 | version = "1.0.49" | 1748 | version = "1.0.50" |
1731 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1749 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1732 | checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" | 1750 | checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" |
1733 | dependencies = [ | 1751 | dependencies = [ |
1734 | "proc-macro2", | 1752 | "proc-macro2", |
1735 | "quote", | 1753 | "quote", |
@@ -1748,14 +1766,15 @@ dependencies = [ | |||
1748 | 1766 | ||
1749 | [[package]] | 1767 | [[package]] |
1750 | name = "time" | 1768 | name = "time" |
1751 | version = "0.3.29" | 1769 | version = "0.3.30" |
1752 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1770 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1753 | checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" | 1771 | checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" |
1754 | dependencies = [ | 1772 | dependencies = [ |
1755 | "deranged", | 1773 | "deranged", |
1756 | "itoa", | 1774 | "itoa", |
1757 | "libc", | 1775 | "libc", |
1758 | "num_threads", | 1776 | "num_threads", |
1777 | "powerfmt", | ||
1759 | "serde", | 1778 | "serde", |
1760 | "time-core", | 1779 | "time-core", |
1761 | "time-macros", | 1780 | "time-macros", |
@@ -1793,9 +1812,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" | |||
1793 | 1812 | ||
1794 | [[package]] | 1813 | [[package]] |
1795 | name = "tokio" | 1814 | name = "tokio" |
1796 | version = "1.32.0" | 1815 | version = "1.33.0" |
1797 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1816 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1798 | checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" | 1817 | checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" |
1799 | dependencies = [ | 1818 | dependencies = [ |
1800 | "backtrace", | 1819 | "backtrace", |
1801 | "bytes", | 1820 | "bytes", |
@@ -1803,7 +1822,7 @@ dependencies = [ | |||
1803 | "mio", | 1822 | "mio", |
1804 | "num_cpus", | 1823 | "num_cpus", |
1805 | "pin-project-lite", | 1824 | "pin-project-lite", |
1806 | "socket2 0.5.4", | 1825 | "socket2 0.5.5", |
1807 | "tokio-macros", | 1826 | "tokio-macros", |
1808 | "windows-sys", | 1827 | "windows-sys", |
1809 | ] | 1828 | ] |
@@ -1869,11 +1888,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" | |||
1869 | 1888 | ||
1870 | [[package]] | 1889 | [[package]] |
1871 | name = "tracing" | 1890 | name = "tracing" |
1872 | version = "0.1.37" | 1891 | version = "0.1.40" |
1873 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1892 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1874 | checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" | 1893 | checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" |
1875 | dependencies = [ | 1894 | dependencies = [ |
1876 | "cfg-if", | ||
1877 | "log", | 1895 | "log", |
1878 | "pin-project-lite", | 1896 | "pin-project-lite", |
1879 | "tracing-attributes", | 1897 | "tracing-attributes", |
@@ -1882,9 +1900,9 @@ dependencies = [ | |||
1882 | 1900 | ||
1883 | [[package]] | 1901 | [[package]] |
1884 | name = "tracing-attributes" | 1902 | name = "tracing-attributes" |
1885 | version = "0.1.26" | 1903 | version = "0.1.27" |
1886 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1904 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1887 | checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" | 1905 | checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" |
1888 | dependencies = [ | 1906 | dependencies = [ |
1889 | "proc-macro2", | 1907 | "proc-macro2", |
1890 | "quote", | 1908 | "quote", |
@@ -1893,9 +1911,9 @@ dependencies = [ | |||
1893 | 1911 | ||
1894 | [[package]] | 1912 | [[package]] |
1895 | name = "tracing-core" | 1913 | name = "tracing-core" |
1896 | version = "0.1.31" | 1914 | version = "0.1.32" |
1897 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1915 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1898 | checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" | 1916 | checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" |
1899 | dependencies = [ | 1917 | dependencies = [ |
1900 | "once_cell", | 1918 | "once_cell", |
1901 | "valuable", | 1919 | "valuable", |
diff --git a/docker-compose.yml b/docker-compose.yml index 9d73e9b..abac64e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml | |||
@@ -6,7 +6,8 @@ services: | |||
6 | container_name: webol_dev_postgres | 6 | container_name: webol_dev_postgres |
7 | restart: no | 7 | restart: no |
8 | environment: | 8 | environment: |
9 | POSTGRES_PASSWORD: postgres | 9 | - POSTGRES_PASSWORD=postgres |
10 | - POSTGRES_DB=webol | ||
10 | 11 | ||
11 | ports: | 12 | ports: |
12 | - "5432:5432" | 13 | - "5432:5432" |
diff --git a/migrations/20231009123228_devices.sql b/migrations/20231009123228_devices.sql index 5856c3a..9d0c7ca 100644 --- a/migrations/20231009123228_devices.sql +++ b/migrations/20231009123228_devices.sql | |||
@@ -1,7 +1,7 @@ | |||
1 | -- Add migration script here | 1 | -- Add migration script here |
2 | CREATE TABLE "devices" | 2 | CREATE TABLE IF NOT EXISTS "devices" |
3 | ( | 3 | ( |
4 | "id" TEXT PRIMARY KEY NOT NULL, | 4 | "id" TEXT PRIMARY KEY NOT NULL, |
5 | "mac" TEXT NOT NULL, | 5 | "mac" TEXT NOT NULL, |
6 | "broadcast_addr" TEXT NOT NULL | 6 | "broadcast_addr" TEXT NOT NULL |
7 | ) \ No newline at end of file | 7 | ) |
diff --git a/src/auth.rs b/src/auth.rs index 81e798f..0fffa60 100644 --- a/src/auth.rs +++ b/src/auth.rs | |||
@@ -25,6 +25,7 @@ pub fn auth(secret: Option<&HeaderValue>) -> Result<bool, AuthError> { | |||
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | #[derive(Debug)] | ||
28 | pub enum AuthError { | 29 | pub enum AuthError { |
29 | WrongSecret, | 30 | WrongSecret, |
30 | MissingSecret, | 31 | MissingSecret, |
@@ -42,4 +43,4 @@ impl AuthError { | |||
42 | }, | 43 | }, |
43 | } | 44 | } |
44 | } | 45 | } |
45 | } \ No newline at end of file | 46 | } |
@@ -1,8 +1,32 @@ | |||
1 | use std::env; | ||
2 | |||
1 | use serde::Serialize; | 3 | use serde::Serialize; |
4 | use sqlx::{PgPool, postgres::PgPoolOptions}; | ||
5 | use tracing::{debug, info}; | ||
2 | 6 | ||
3 | #[derive(Serialize)] | 7 | #[derive(Serialize)] |
4 | pub struct Device { | 8 | pub struct Device { |
5 | pub id: String, | 9 | pub id: String, |
6 | pub mac: String, | 10 | pub mac: String, |
7 | pub broadcast_addr: String | 11 | pub broadcast_addr: String |
8 | } \ No newline at end of file | 12 | } |
13 | |||
14 | pub async fn init_db_pool() -> PgPool { | ||
15 | #[cfg(not(debug_assertions))] | ||
16 | let db_url = SETTINGS.get_string("database.url").unwrap(); | ||
17 | |||
18 | #[cfg(debug_assertions)] | ||
19 | let db_url = env::var("DATABASE_URL").unwrap(); | ||
20 | |||
21 | debug!("attempt to connect dbPool to '{}'", db_url); | ||
22 | |||
23 | let pool = PgPoolOptions::new() | ||
24 | .max_connections(5) | ||
25 | .connect(&db_url) | ||
26 | .await | ||
27 | .unwrap(); | ||
28 | |||
29 | info!("dbPool successfully connected to '{}'", db_url); | ||
30 | |||
31 | pool | ||
32 | } | ||
diff --git a/src/error.rs b/src/error.rs index afed111..db2fc86 100644 --- a/src/error.rs +++ b/src/error.rs | |||
@@ -6,6 +6,7 @@ use serde_json::json; | |||
6 | use tracing::error; | 6 | use tracing::error; |
7 | use crate::auth::AuthError; | 7 | use crate::auth::AuthError; |
8 | 8 | ||
9 | #[derive(Debug)] | ||
9 | pub enum WebolError { | 10 | pub enum WebolError { |
10 | Auth(AuthError), | 11 | Auth(AuthError), |
11 | Generic, | 12 | Generic, |
diff --git a/src/main.rs b/src/main.rs index b7306ea..ce12cf6 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -3,11 +3,11 @@ use std::sync::Arc; | |||
3 | use axum::{Router, routing::post}; | 3 | use axum::{Router, routing::post}; |
4 | use axum::routing::{get, put}; | 4 | use axum::routing::{get, put}; |
5 | use sqlx::PgPool; | 5 | use sqlx::PgPool; |
6 | use sqlx::postgres::PgPoolOptions; | ||
7 | use time::util::local_offset; | 6 | use time::util::local_offset; |
8 | use tracing::{debug, info, level_filters::LevelFilter}; | 7 | use tracing::{info, level_filters::LevelFilter}; |
9 | use tracing_subscriber::{EnvFilter, fmt::{self, time::LocalTime}, prelude::*}; | 8 | use tracing_subscriber::{EnvFilter, fmt::{self, time::LocalTime}, prelude::*}; |
10 | use crate::config::SETTINGS; | 9 | use crate::config::SETTINGS; |
10 | use crate::db::init_db_pool; | ||
11 | use crate::routes::device::{get_device, post_device, put_device}; | 11 | use crate::routes::device::{get_device, post_device, put_device}; |
12 | use crate::routes::start::start; | 12 | use crate::routes::start::start; |
13 | 13 | ||
@@ -41,6 +41,7 @@ async fn main() { | |||
41 | info!("start webol v{}", version); | 41 | info!("start webol v{}", version); |
42 | 42 | ||
43 | let db = init_db_pool().await; | 43 | let db = init_db_pool().await; |
44 | sqlx::migrate!().run(&db).await.unwrap(); | ||
44 | 45 | ||
45 | let shared_state = Arc::new(AppState { db }); | 46 | let shared_state = Arc::new(AppState { db }); |
46 | 47 | ||
@@ -62,23 +63,3 @@ async fn main() { | |||
62 | pub struct AppState { | 63 | pub struct AppState { |
63 | db: PgPool | 64 | db: PgPool |
64 | } | 65 | } |
65 | |||
66 | async fn init_db_pool() -> PgPool { | ||
67 | #[cfg(not(debug_assertions))] | ||
68 | let db_url = SETTINGS.get_string("database.url").unwrap(); | ||
69 | |||
70 | #[cfg(debug_assertions)] | ||
71 | let db_url = env::var("DATABASE_URL").unwrap(); | ||
72 | |||
73 | debug!("attempt to connect dbPool to '{}'", db_url); | ||
74 | |||
75 | let pool = PgPoolOptions::new() | ||
76 | .max_connections(5) | ||
77 | .connect(&db_url) | ||
78 | .await | ||
79 | .unwrap(); | ||
80 | |||
81 | info!("dbPool successfully connected to '{}'", db_url); | ||
82 | |||
83 | pool | ||
84 | } | ||