From 29c1fc8f829196a464f8d91a03c40ee18a43c57c Mon Sep 17 00:00:00 2001 From: Imbus Date: Tue, 14 Nov 2023 08:40:45 +0100 Subject: [PATCH] Ported the project from sqlite to postgres --- container/Containerfile | 3 + container/ContainerfileDebug | 3 + justfile | 72 +-- ...dcaf05b21c79d47fe008e209191157f5697e.json} | 12 +- ...4a204ddf3d75be6666fca3624deb35c0aaa97.json | 30 +- ...4493e8bcb8c10687d0f8c0592fe38ed956fa6.json | 20 - ...3d302d083ec5333f3a5ce04113c38a041100.json} | 26 +- ...e41065974104b735d96b3c5785480023bb60a.json | 12 - ...eec79860b1f3119c4025f541e7d724ed381be.json | 4 +- ...508b8397ef7fbb9eb521ac3c5e57206eeecf7.json | 15 + ...d4ccde65b4858124c174988ff72847704e305.json | 30 +- ...683fdc706751e2bb69043544c9a4d08b5ba0.json} | 36 +- ...95a2598bb69984d6023e38eeea54454887b90.json | 12 - ...f93050b7d35c66c0fe0c86f7b2dcdb7a1e3eb.json | 15 + ...84fda1072913b29bb6b3753a0d351583dfff6.json | 22 + ...76ed4da34e450fc07b812f6bf77073cc2128.json} | 37 +- server/Cargo.lock | 492 ++++++++++-------- server/Cargo.toml | 2 +- server/migrations_pg/0001_users_table.sql | 38 ++ server/migrations_pg/0002_posts_table.sql | 43 ++ server/src/db.rs | 28 +- server/src/routes/post.rs | 2 +- server/src/state.rs | 21 +- 23 files changed, 566 insertions(+), 409 deletions(-) rename server/.sqlx/{query-fdbb1cd2873a5c866faaf3a60185d1f98e14198655aa536c2227ef8d2c6b88e1.json => query-16e84d577155f3c47fcb736bbad4dcaf05b21c79d47fe008e209191157f5697e.json} (50%) delete mode 100644 server/.sqlx/query-2e61cd30a6cd3e0937dd096b4f94493e8bcb8c10687d0f8c0592fe38ed956fa6.json rename server/.sqlx/{query-98f4c0bfff04e07f5d0a46d48a31d24655826eebdf09c7f9f45d770df02035d3.json => query-606364c79e0990deb07dfbe6c32b3d302d083ec5333f3a5ce04113c38a041100.json} (65%) delete mode 100644 server/.sqlx/query-78ecd3bc5a999dc227a86556f0ce41065974104b735d96b3c5785480023bb60a.json create mode 100644 server/.sqlx/query-a2835289cba16d38401e5324876508b8397ef7fbb9eb521ac3c5e57206eeecf7.json rename server/.sqlx/{query-da280dfbdfe992918eb4f25ca61c08fc01474c3753a63e05b02051f5c066abc2.json => query-b6019471ff1989ef2f0658b0b34e683fdc706751e2bb69043544c9a4d08b5ba0.json} (64%) delete mode 100644 server/.sqlx/query-c2804e9c7bbd92dcddc34dd6f9d95a2598bb69984d6023e38eeea54454887b90.json create mode 100644 server/.sqlx/query-c936f44864dafe4660a736babd5f93050b7d35c66c0fe0c86f7b2dcdb7a1e3eb.json create mode 100644 server/.sqlx/query-dd99e48b1572e25db38f03da95984fda1072913b29bb6b3753a0d351583dfff6.json rename server/.sqlx/{query-8f5e9d8d0c7c33d31f02a9cbd9886ed945d788caeb704b2ee5f743f7bf5fac88.json => query-f68cd95363d7da716b14f430118176ed4da34e450fc07b812f6bf77073cc2128.json} (62%) create mode 100644 server/migrations_pg/0001_users_table.sql create mode 100644 server/migrations_pg/0002_posts_table.sql diff --git a/container/Containerfile b/container/Containerfile index 5847ac1..bb41baf 100644 --- a/container/Containerfile +++ b/container/Containerfile @@ -25,6 +25,9 @@ RUN cargo build --target x86_64-unknown-linux-musl --release RUN rm src/*.rs ADD server /build-container +# Make sure sqlx reads from .sqlx directory +ENV SQLX_OFFLINE true + RUN cargo build --target x86_64-unknown-linux-musl --release # Final stage, copy the server binary and the frontend build diff --git a/container/ContainerfileDebug b/container/ContainerfileDebug index 5f745c2..31c4ac9 100644 --- a/container/ContainerfileDebug +++ b/container/ContainerfileDebug @@ -22,6 +22,9 @@ RUN cargo build --target x86_64-unknown-linux-musl RUN rm src/*.rs ADD server /build-container +# Make sure sqlx reads from .sqlx directory +ENV SQLX_OFFLINE true + # Note that '--release' is missing here, so we build in debug mode RUN cargo build --target x86_64-unknown-linux-musl diff --git a/justfile b/justfile index 8d39699..d40afd2 100644 --- a/justfile +++ b/justfile @@ -1,76 +1,60 @@ -runtime := "podman" - # Builds a debug container and runs it dev: start-debug @echo "Cd into client and run 'npm run dev' to start the client in dev mode." -[private] -npm-install directory: - cd {{directory}} && npm install - -# Builds the client with npm (result in client/dist) -[private] -npm-build directory: (npm-install directory) - cd {{directory}} && npm run build - @echo "Built client at {{directory}}/dist" - # Builds a debug container [private] build-container-server-debug: - {{runtime}} build -t fb-server-debug -f container/ContainerfileDebug . + podman build -t fb-server-debug -f container/ContainerfileDebug . # Builds a debug container and runs it [private] -start-debug: build-container-server-debug remove-podman-containers - {{runtime}} run -d -e DATABASE_URL=sqlite:debug.db -p 8080:8080 --name frostbyte-debug fb-server-debug +start-debug: start-postgres-dev clean-podman init-sqlx build-container-server-debug + podman network create fb_network --ignore + podman run -d --network fb_network -e DATABASE_URL=postgres://postgres:password@postgres:5432/frostbyte -p 8080:8080 --name frostbyte-debug fb-server-debug @echo "Debug server started." # Builds a release container [private] build-container-release: - {{runtime}} build -t fb-server -f container/Containerfile . + podman build -t fb-server -f container/Containerfile . # Builds a release container and runs it -start-release: build-container-release remove-podman-containers - {{runtime}} network create fb_network --ignore - {{runtime}} run -d --network fb_network -e DATABASE_URL=sqlite:release.db -p 8080:8080 --name frostbyte fb-server +start-release: start-postgres-dev clean-podman init-sqlx build-container-release + podman network create fb_network --ignore + podman run -d --network fb_network -e DATABASE_URL=postgres://postgres:password@postgres:5432/frostbyte -p 8080:8080 --name frostbyte fb-server +# Initializes the database, runs migrations and then prepares sqlx init-sqlx: - echo "DATABASE_URL=sqlite:debug.db" > server/.env - cd server && sqlx database create - cd server && sqlx migrate run + echo "DATABASE_URL=postgres://postgres:password@localhost:5432/frostbyte" > server/.env + cd server && sqlx database create --connect-timeout 40 # Postgres takes a while to start up + cd server && sqlx migrate run --source migrations_pg cd server && cargo sqlx prepare -# Removes and stops any containers related to the project +# Starts a postgres container for development [private] -remove-podman-containers: - {{runtime}} network rm -f fb_network - {{runtime}} container rm -f frostbyte - {{runtime}} container rm -f frostbyte-debug +start-postgres-dev: + podman rm -f postgres + podman run --network fb_network --name postgres -e POSTGRES_PASSWORD=password -d -p 5432:5432 docker.io/postgres:16.1-alpine -# Deletes everything podman related (even unrelated to the project) +# Forcefully stops and removes the frostbyte container [private] -prune-podman: - {{runtime}} stop -a - {{runtime}} rm -af - {{runtime}} image rm -af - {{runtime}} system prune -af - {{runtime}} system reset --force +clean-podman: + podman container rm -f frostbyte + podman container rm -f frostbyte-debug + +# Forcefully removes the frostbyte images +[private] +clean-images: + podman image rm -f fb-server + podman image rm -f fb-server-debug # Cleans up everything related to the project -clean: - {{runtime}} container rm -f frostbyte - {{runtime}} container rm -f frostbyte-debug - {{runtime}} image rm -f fb-server - {{runtime}} image rm -f fb-server-debug +clean: clean-podman clean-images rm -rf client/dist rm -rf client/node_modules rm -rf client-solid/dist rm -rf client-solid/node_modules rm -rf server/public rm -rf server/target - @echo "Cleaned up! Make sure to run 'just nuke' to nuke everything podman related." - -# Nukes everything. No mercy. Leave no trace. -nuke: clean prune-podman - @echo "Nuked everything! You're starting from scratch now." + @echo "Cleaned up! Make sure to clean up podman volumes and networks." \ No newline at end of file diff --git a/server/.sqlx/query-fdbb1cd2873a5c866faaf3a60185d1f98e14198655aa536c2227ef8d2c6b88e1.json b/server/.sqlx/query-16e84d577155f3c47fcb736bbad4dcaf05b21c79d47fe008e209191157f5697e.json similarity index 50% rename from server/.sqlx/query-fdbb1cd2873a5c866faaf3a60185d1f98e14198655aa536c2227ef8d2c6b88e1.json rename to server/.sqlx/query-16e84d577155f3c47fcb736bbad4dcaf05b21c79d47fe008e209191157f5697e.json index 68b5108..6f27da0 100644 --- a/server/.sqlx/query-fdbb1cd2873a5c866faaf3a60185d1f98e14198655aa536c2227ef8d2c6b88e1.json +++ b/server/.sqlx/query-16e84d577155f3c47fcb736bbad4dcaf05b21c79d47fe008e209191157f5697e.json @@ -1,20 +1,22 @@ { - "db_name": "SQLite", - "query": "SELECT username FROM users WHERE username = ?", + "db_name": "PostgreSQL", + "query": "SELECT username FROM users WHERE username = $1", "describe": { "columns": [ { - "name": "username", "ordinal": 0, + "name": "username", "type_info": "Text" } ], "parameters": { - "Right": 1 + "Left": [ + "Text" + ] }, "nullable": [ false ] }, - "hash": "fdbb1cd2873a5c866faaf3a60185d1f98e14198655aa536c2227ef8d2c6b88e1" + "hash": "16e84d577155f3c47fcb736bbad4dcaf05b21c79d47fe008e209191157f5697e" } diff --git a/server/.sqlx/query-1cff76615ce5fb26bd9fbb23cbe4a204ddf3d75be6666fca3624deb35c0aaa97.json b/server/.sqlx/query-1cff76615ce5fb26bd9fbb23cbe4a204ddf3d75be6666fca3624deb35c0aaa97.json index cd7e9cb..ee38c27 100644 --- a/server/.sqlx/query-1cff76615ce5fb26bd9fbb23cbe4a204ddf3d75be6666fca3624deb35c0aaa97.json +++ b/server/.sqlx/query-1cff76615ce5fb26bd9fbb23cbe4a204ddf3d75be6666fca3624deb35c0aaa97.json @@ -1,46 +1,46 @@ { - "db_name": "SQLite", + "db_name": "PostgreSQL", "query": "SELECT * FROM posts WHERE id = (SELECT MAX(id) FROM posts)", "describe": { "columns": [ { - "name": "id", "ordinal": 0, - "type_info": "Int64" + "name": "id", + "type_info": "Int8" }, { - "name": "user_id", "ordinal": 1, - "type_info": "Int64" + "name": "user_id", + "type_info": "Int8" }, { - "name": "content", "ordinal": 2, + "name": "content", "type_info": "Text" }, { - "name": "upvotes", "ordinal": 3, - "type_info": "Int64" + "name": "upvotes", + "type_info": "Int4" }, { - "name": "downvotes", "ordinal": 4, - "type_info": "Int64" + "name": "downvotes", + "type_info": "Int4" }, { - "name": "created_at", "ordinal": 5, - "type_info": "Datetime" + "name": "created_at", + "type_info": "Timestamp" }, { - "name": "updated_at", "ordinal": 6, - "type_info": "Datetime" + "name": "updated_at", + "type_info": "Timestamp" } ], "parameters": { - "Right": 0 + "Left": [] }, "nullable": [ false, diff --git a/server/.sqlx/query-2e61cd30a6cd3e0937dd096b4f94493e8bcb8c10687d0f8c0592fe38ed956fa6.json b/server/.sqlx/query-2e61cd30a6cd3e0937dd096b4f94493e8bcb8c10687d0f8c0592fe38ed956fa6.json deleted file mode 100644 index afb4fda..0000000 --- a/server/.sqlx/query-2e61cd30a6cd3e0937dd096b4f94493e8bcb8c10687d0f8c0592fe38ed956fa6.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT id FROM users WHERE username = ?", - "describe": { - "columns": [ - { - "name": "id", - "ordinal": 0, - "type_info": "Int64" - } - ], - "parameters": { - "Right": 1 - }, - "nullable": [ - false - ] - }, - "hash": "2e61cd30a6cd3e0937dd096b4f94493e8bcb8c10687d0f8c0592fe38ed956fa6" -} diff --git a/server/.sqlx/query-98f4c0bfff04e07f5d0a46d48a31d24655826eebdf09c7f9f45d770df02035d3.json b/server/.sqlx/query-606364c79e0990deb07dfbe6c32b3d302d083ec5333f3a5ce04113c38a041100.json similarity index 65% rename from server/.sqlx/query-98f4c0bfff04e07f5d0a46d48a31d24655826eebdf09c7f9f45d770df02035d3.json rename to server/.sqlx/query-606364c79e0990deb07dfbe6c32b3d302d083ec5333f3a5ce04113c38a041100.json index 09d4c19..95b411b 100644 --- a/server/.sqlx/query-98f4c0bfff04e07f5d0a46d48a31d24655826eebdf09c7f9f45d770df02035d3.json +++ b/server/.sqlx/query-606364c79e0990deb07dfbe6c32b3d302d083ec5333f3a5ce04113c38a041100.json @@ -1,36 +1,38 @@ { - "db_name": "SQLite", - "query": "SELECT * FROM users WHERE username = ?", + "db_name": "PostgreSQL", + "query": "SELECT * FROM users WHERE username = $1", "describe": { "columns": [ { - "name": "id", "ordinal": 0, - "type_info": "Int64" + "name": "id", + "type_info": "Int8" }, { - "name": "username", "ordinal": 1, + "name": "username", "type_info": "Text" }, { - "name": "password", "ordinal": 2, + "name": "password", "type_info": "Text" }, { - "name": "created_at", "ordinal": 3, - "type_info": "Datetime" + "name": "created_at", + "type_info": "Timestamp" }, { - "name": "updated_at", "ordinal": 4, - "type_info": "Datetime" + "name": "updated_at", + "type_info": "Timestamp" } ], "parameters": { - "Right": 1 + "Left": [ + "Text" + ] }, "nullable": [ false, @@ -40,5 +42,5 @@ false ] }, - "hash": "98f4c0bfff04e07f5d0a46d48a31d24655826eebdf09c7f9f45d770df02035d3" + "hash": "606364c79e0990deb07dfbe6c32b3d302d083ec5333f3a5ce04113c38a041100" } diff --git a/server/.sqlx/query-78ecd3bc5a999dc227a86556f0ce41065974104b735d96b3c5785480023bb60a.json b/server/.sqlx/query-78ecd3bc5a999dc227a86556f0ce41065974104b735d96b3c5785480023bb60a.json deleted file mode 100644 index 3f0c25a..0000000 --- a/server/.sqlx/query-78ecd3bc5a999dc227a86556f0ce41065974104b735d96b3c5785480023bb60a.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO users (username, password) VALUES (?, ?)", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "78ecd3bc5a999dc227a86556f0ce41065974104b735d96b3c5785480023bb60a" -} diff --git a/server/.sqlx/query-8c06e65c10e3a2eee83cfe51628eec79860b1f3119c4025f541e7d724ed381be.json b/server/.sqlx/query-8c06e65c10e3a2eee83cfe51628eec79860b1f3119c4025f541e7d724ed381be.json index 0bb7904..3e6e377 100644 --- a/server/.sqlx/query-8c06e65c10e3a2eee83cfe51628eec79860b1f3119c4025f541e7d724ed381be.json +++ b/server/.sqlx/query-8c06e65c10e3a2eee83cfe51628eec79860b1f3119c4025f541e7d724ed381be.json @@ -1,10 +1,10 @@ { - "db_name": "SQLite", + "db_name": "PostgreSQL", "query": "INSERT INTO posts (user_id, content) VALUES (1, 'Hello world! The demo username is user and the password is pass.')", "describe": { "columns": [], "parameters": { - "Right": 0 + "Left": [] }, "nullable": [] }, diff --git a/server/.sqlx/query-a2835289cba16d38401e5324876508b8397ef7fbb9eb521ac3c5e57206eeecf7.json b/server/.sqlx/query-a2835289cba16d38401e5324876508b8397ef7fbb9eb521ac3c5e57206eeecf7.json new file mode 100644 index 0000000..829ba62 --- /dev/null +++ b/server/.sqlx/query-a2835289cba16d38401e5324876508b8397ef7fbb9eb521ac3c5e57206eeecf7.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO posts (user_id, content) VALUES ($1, $2)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Int8", + "Text" + ] + }, + "nullable": [] + }, + "hash": "a2835289cba16d38401e5324876508b8397ef7fbb9eb521ac3c5e57206eeecf7" +} diff --git a/server/.sqlx/query-abd3af0c2a9ba20eab7116a2d5ed4ccde65b4858124c174988ff72847704e305.json b/server/.sqlx/query-abd3af0c2a9ba20eab7116a2d5ed4ccde65b4858124c174988ff72847704e305.json index 70cdc6f..887d325 100644 --- a/server/.sqlx/query-abd3af0c2a9ba20eab7116a2d5ed4ccde65b4858124c174988ff72847704e305.json +++ b/server/.sqlx/query-abd3af0c2a9ba20eab7116a2d5ed4ccde65b4858124c174988ff72847704e305.json @@ -1,46 +1,46 @@ { - "db_name": "SQLite", + "db_name": "PostgreSQL", "query": "SELECT * FROM posts WHERE id = 1", "describe": { "columns": [ { - "name": "id", "ordinal": 0, - "type_info": "Int64" + "name": "id", + "type_info": "Int8" }, { - "name": "user_id", "ordinal": 1, - "type_info": "Int64" + "name": "user_id", + "type_info": "Int8" }, { - "name": "content", "ordinal": 2, + "name": "content", "type_info": "Text" }, { - "name": "upvotes", "ordinal": 3, - "type_info": "Int64" + "name": "upvotes", + "type_info": "Int4" }, { - "name": "downvotes", "ordinal": 4, - "type_info": "Int64" + "name": "downvotes", + "type_info": "Int4" }, { - "name": "created_at", "ordinal": 5, - "type_info": "Datetime" + "name": "created_at", + "type_info": "Timestamp" }, { - "name": "updated_at", "ordinal": 6, - "type_info": "Datetime" + "name": "updated_at", + "type_info": "Timestamp" } ], "parameters": { - "Right": 0 + "Left": [] }, "nullable": [ false, diff --git a/server/.sqlx/query-da280dfbdfe992918eb4f25ca61c08fc01474c3753a63e05b02051f5c066abc2.json b/server/.sqlx/query-b6019471ff1989ef2f0658b0b34e683fdc706751e2bb69043544c9a4d08b5ba0.json similarity index 64% rename from server/.sqlx/query-da280dfbdfe992918eb4f25ca61c08fc01474c3753a63e05b02051f5c066abc2.json rename to server/.sqlx/query-b6019471ff1989ef2f0658b0b34e683fdc706751e2bb69043544c9a4d08b5ba0.json index 7c57d88..59d20e9 100644 --- a/server/.sqlx/query-da280dfbdfe992918eb4f25ca61c08fc01474c3753a63e05b02051f5c066abc2.json +++ b/server/.sqlx/query-b6019471ff1989ef2f0658b0b34e683fdc706751e2bb69043544c9a4d08b5ba0.json @@ -1,46 +1,48 @@ { - "db_name": "SQLite", - "query": "SELECT * FROM posts WHERE id = ?", + "db_name": "PostgreSQL", + "query": "SELECT * FROM posts WHERE id = $1", "describe": { "columns": [ { - "name": "id", "ordinal": 0, - "type_info": "Int64" + "name": "id", + "type_info": "Int8" }, { - "name": "user_id", "ordinal": 1, - "type_info": "Int64" + "name": "user_id", + "type_info": "Int8" }, { - "name": "content", "ordinal": 2, + "name": "content", "type_info": "Text" }, { - "name": "upvotes", "ordinal": 3, - "type_info": "Int64" + "name": "upvotes", + "type_info": "Int4" }, { - "name": "downvotes", "ordinal": 4, - "type_info": "Int64" + "name": "downvotes", + "type_info": "Int4" }, { - "name": "created_at", "ordinal": 5, - "type_info": "Datetime" + "name": "created_at", + "type_info": "Timestamp" }, { - "name": "updated_at", "ordinal": 6, - "type_info": "Datetime" + "name": "updated_at", + "type_info": "Timestamp" } ], "parameters": { - "Right": 1 + "Left": [ + "Int8" + ] }, "nullable": [ false, @@ -52,5 +54,5 @@ false ] }, - "hash": "da280dfbdfe992918eb4f25ca61c08fc01474c3753a63e05b02051f5c066abc2" + "hash": "b6019471ff1989ef2f0658b0b34e683fdc706751e2bb69043544c9a4d08b5ba0" } diff --git a/server/.sqlx/query-c2804e9c7bbd92dcddc34dd6f9d95a2598bb69984d6023e38eeea54454887b90.json b/server/.sqlx/query-c2804e9c7bbd92dcddc34dd6f9d95a2598bb69984d6023e38eeea54454887b90.json deleted file mode 100644 index 0dd732c..0000000 --- a/server/.sqlx/query-c2804e9c7bbd92dcddc34dd6f9d95a2598bb69984d6023e38eeea54454887b90.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "db_name": "SQLite", - "query": "INSERT INTO posts (user_id, content) VALUES (?, ?)", - "describe": { - "columns": [], - "parameters": { - "Right": 2 - }, - "nullable": [] - }, - "hash": "c2804e9c7bbd92dcddc34dd6f9d95a2598bb69984d6023e38eeea54454887b90" -} diff --git a/server/.sqlx/query-c936f44864dafe4660a736babd5f93050b7d35c66c0fe0c86f7b2dcdb7a1e3eb.json b/server/.sqlx/query-c936f44864dafe4660a736babd5f93050b7d35c66c0fe0c86f7b2dcdb7a1e3eb.json new file mode 100644 index 0000000..f61e0d7 --- /dev/null +++ b/server/.sqlx/query-c936f44864dafe4660a736babd5f93050b7d35c66c0fe0c86f7b2dcdb7a1e3eb.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO users (username, password) VALUES ($1, $2)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text", + "Text" + ] + }, + "nullable": [] + }, + "hash": "c936f44864dafe4660a736babd5f93050b7d35c66c0fe0c86f7b2dcdb7a1e3eb" +} diff --git a/server/.sqlx/query-dd99e48b1572e25db38f03da95984fda1072913b29bb6b3753a0d351583dfff6.json b/server/.sqlx/query-dd99e48b1572e25db38f03da95984fda1072913b29bb6b3753a0d351583dfff6.json new file mode 100644 index 0000000..ebf9b7e --- /dev/null +++ b/server/.sqlx/query-dd99e48b1572e25db38f03da95984fda1072913b29bb6b3753a0d351583dfff6.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT id FROM users WHERE username = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "dd99e48b1572e25db38f03da95984fda1072913b29bb6b3753a0d351583dfff6" +} diff --git a/server/.sqlx/query-8f5e9d8d0c7c33d31f02a9cbd9886ed945d788caeb704b2ee5f743f7bf5fac88.json b/server/.sqlx/query-f68cd95363d7da716b14f430118176ed4da34e450fc07b812f6bf77073cc2128.json similarity index 62% rename from server/.sqlx/query-8f5e9d8d0c7c33d31f02a9cbd9886ed945d788caeb704b2ee5f743f7bf5fac88.json rename to server/.sqlx/query-f68cd95363d7da716b14f430118176ed4da34e450fc07b812f6bf77073cc2128.json index 013443f..adf548e 100644 --- a/server/.sqlx/query-8f5e9d8d0c7c33d31f02a9cbd9886ed945d788caeb704b2ee5f743f7bf5fac88.json +++ b/server/.sqlx/query-f68cd95363d7da716b14f430118176ed4da34e450fc07b812f6bf77073cc2128.json @@ -1,46 +1,49 @@ { - "db_name": "SQLite", - "query": "SELECT * FROM posts ORDER BY created_at DESC LIMIT ? OFFSET ?", + "db_name": "PostgreSQL", + "query": "SELECT * FROM posts ORDER BY created_at DESC LIMIT $1 OFFSET $2", "describe": { "columns": [ { - "name": "id", "ordinal": 0, - "type_info": "Int64" + "name": "id", + "type_info": "Int8" }, { - "name": "user_id", "ordinal": 1, - "type_info": "Int64" + "name": "user_id", + "type_info": "Int8" }, { - "name": "content", "ordinal": 2, + "name": "content", "type_info": "Text" }, { - "name": "upvotes", "ordinal": 3, - "type_info": "Int64" + "name": "upvotes", + "type_info": "Int4" }, { - "name": "downvotes", "ordinal": 4, - "type_info": "Int64" + "name": "downvotes", + "type_info": "Int4" }, { - "name": "created_at", "ordinal": 5, - "type_info": "Datetime" + "name": "created_at", + "type_info": "Timestamp" }, { - "name": "updated_at", "ordinal": 6, - "type_info": "Datetime" + "name": "updated_at", + "type_info": "Timestamp" } ], "parameters": { - "Right": 2 + "Left": [ + "Int8", + "Int8" + ] }, "nullable": [ false, @@ -52,5 +55,5 @@ false ] }, - "hash": "8f5e9d8d0c7c33d31f02a9cbd9886ed945d788caeb704b2ee5f743f7bf5fac88" + "hash": "f68cd95363d7da716b14f430118176ed4da34e450fc07b812f6bf77073cc2128" } diff --git a/server/Cargo.lock b/server/Cargo.lock index 3dfcfc7..1485d9a 100755 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -53,8 +53,8 @@ dependencies = [ "actix-service", "actix-utils", "ahash", - "base64 0.21.4", - "bitflags 2.4.0", + "base64 0.21.5", + "bitflags 2.4.1", "brotli", "bytes", "bytestring", @@ -88,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -201,7 +201,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -221,21 +221,22 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "getrandom", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] @@ -278,9 +279,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.5.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" dependencies = [ "anstyle", "anstyle-parse", @@ -292,15 +293,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" dependencies = [ "utf8parse", ] @@ -316,9 +317,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "2.1.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" dependencies = [ "anstyle", "windows-sys", @@ -381,9 +382,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -411,9 +412,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" dependencies = [ "serde", ] @@ -438,9 +439,9 @@ dependencies = [ [[package]] name = "brotli" -version = "3.3.4" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -449,9 +450,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "2.3.4" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" +checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -465,9 +466,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" @@ -477,20 +478,19 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bytestring" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae" +checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" dependencies = [ "bytes", ] [[package]] name = "cc" -version = "1.0.83" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856" dependencies = [ - "jobserver", "libc", ] @@ -517,9 +517,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.5" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824956d0dca8334758a5b7f7e50518d66ea319330cbceedcf76905c2f6ab30e3" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.5" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122ec64120a49b4563ccaedcbea7818d069ed8e9aa6d829b82d8a4128936b2ab" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", @@ -539,21 +539,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "colorchoice" @@ -592,9 +592,9 @@ checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -610,9 +610,9 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" @@ -678,9 +678,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] [[package]] name = "derive_more" @@ -733,9 +736,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -752,25 +755,14 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" dependencies = [ - "errno-dragonfly", "libc", "windows-sys", ] -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "etcetera" version = "0.8.0" @@ -802,9 +794,9 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -848,9 +840,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -858,15 +850,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -886,27 +878,27 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-core", "futures-io", @@ -939,9 +931,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", @@ -981,9 +973,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ "ahash", "allocator-api2", @@ -995,7 +987,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.14.1", + "hashbrown 0.14.2", ] [[package]] @@ -1048,9 +1040,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -1083,16 +1075,16 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows", + "windows-core", ] [[package]] @@ -1126,12 +1118,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.2", ] [[package]] @@ -1169,20 +1161,11 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" -[[package]] -name = "jobserver" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" -dependencies = [ - "libc", -] - [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -1193,9 +1176,9 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "pem", - "ring", + "ring 0.16.20", "serde", "serde_json", "simple_asn1", @@ -1218,9 +1201,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.148" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libm" @@ -1241,15 +1224,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.7" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "local-channel" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a493488de5f18c8ffcba89eebb8532ffc562dc400490eb65b84893fae0b178" +checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" dependencies = [ "futures-core", "futures-sink", @@ -1258,15 +1241,15 @@ dependencies = [ [[package]] name = "local-waker" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" +checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -1290,9 +1273,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memoffset" @@ -1336,9 +1319,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "log", @@ -1448,7 +1431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.8", + "parking_lot_core 0.9.9", ] [[package]] @@ -1467,13 +1450,13 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.4.1", "smallvec", "windows-targets", ] @@ -1558,6 +1541,12 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[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.17" @@ -1566,9 +1555,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -1623,18 +1612,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.9.5" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", @@ -1644,9 +1633,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -1655,9 +1644,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.5" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "ring" @@ -1669,23 +1658,35 @@ dependencies = [ "libc", "once_cell", "spin 0.5.2", - "untrusted", + "untrusted 0.7.1", "web-sys", "winapi", ] [[package]] -name = "rsa" -version = "0.9.2" +name = "ring" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys", +] + +[[package]] +name = "rsa" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ef35bf3e7fe15a53c4ab08a998e42271eab13eb0db224126bc7bc4c4bad96d" dependencies = [ - "byteorder", "const-oid", "digest", "num-bigint-dig", "num-integer", - "num-iter", "num-traits", "pkcs1", "pkcs8", @@ -1713,17 +1714,47 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.14" +version = "0.38.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f" +checksum = "80109a168d9bc0c7f483083244543a6eb0dba02295d33ca268145e6190d6df0c" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", "windows-sys", ] +[[package]] +name = "rustls" +version = "0.21.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" +dependencies = [ + "ring 0.17.5", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.5", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring 0.17.5", + "untrusted 0.9.0", +] + [[package]] name = "ryu" version = "1.0.15" @@ -1737,36 +1768,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] -name = "semver" -version = "1.0.19" +name = "sct" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring 0.17.5", + "untrusted 0.9.0", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -1839,9 +1880,9 @@ dependencies = [ [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", "rand_core", @@ -1886,15 +1927,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys", @@ -1972,12 +2013,14 @@ dependencies = [ "futures-util", "hashlink", "hex", - "indexmap 2.0.2", + "indexmap 2.1.0", "log", "memchr", "once_cell", "paste", "percent-encoding", + "rustls", + "rustls-pemfile", "serde", "serde_json", "sha2", @@ -1989,6 +2032,7 @@ dependencies = [ "tracing", "url", "uuid", + "webpki-roots", ] [[package]] @@ -2037,8 +2081,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" dependencies = [ "atoi", - "base64 0.21.4", - "bitflags 2.4.0", + "base64 0.21.5", + "bitflags 2.4.1", "byteorder", "bytes", "chrono", @@ -2081,8 +2125,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" dependencies = [ "atoi", - "base64 0.21.4", - "bitflags 2.4.0", + "base64 0.21.5", + "bitflags 2.4.1", "byteorder", "chrono", "crc", @@ -2175,9 +2219,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -2186,13 +2230,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.3.5", + "redox_syscall 0.4.1", "rustix", "windows-sys", ] @@ -2208,32 +2252,33 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "time" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ "deranged", "itoa", + "powerfmt", "serde", "time-core", "time-macros", @@ -2271,9 +2316,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.32.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -2299,9 +2344,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -2313,11 +2358,10 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite", "tracing-attributes", @@ -2326,20 +2370,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] @@ -2398,6 +2442,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.4.1" @@ -2417,9 +2467,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" dependencies = [ "getrandom", "serde", @@ -2445,9 +2495,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2455,24 +2505,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2480,33 +2530,42 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" +dependencies = [ + "rustls-webpki", +] + [[package]] name = "whoami" version = "1.4.1" @@ -2545,10 +2604,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets", ] @@ -2619,6 +2678,26 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "zerocopy" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "zeroize" version = "1.6.0" @@ -2646,11 +2725,10 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.8+zstd.1.5.5" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", - "libc", "pkg-config", ] diff --git a/server/Cargo.toml b/server/Cargo.toml index f770f6e..760eac6 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -19,7 +19,7 @@ log = "0.4.20" serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.107" sled = { version = "0.34.7" } -sqlx = { version = "0.7.2", features = ["sqlite", "runtime-tokio", "chrono", "uuid"] } +sqlx = { version = "0.7.2", features = ["runtime-tokio", "chrono", "uuid", "postgres", "tls-rustls"] } uuid = { version = "1.4.1", features = ["serde", "v4"] } [profile.dev.package.sqlx-macros] diff --git a/server/migrations_pg/0001_users_table.sql b/server/migrations_pg/0001_users_table.sql new file mode 100644 index 0000000..bdeee93 --- /dev/null +++ b/server/migrations_pg/0001_users_table.sql @@ -0,0 +1,38 @@ +CREATE TABLE IF NOT EXISTS users ( + id BIGSERIAL PRIMARY KEY, + username TEXT NOT NULL UNIQUE, + password TEXT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +-- Create a function to set created_at and updated_at on INSERT +CREATE OR REPLACE FUNCTION set_timestamps_on_insert() RETURNS TRIGGER AS $$ +BEGIN + NEW.created_at = NOW(); + NEW.updated_at = NOW(); + RETURN NEW; +END; +$$ LANGUAGE plpgsql; + +-- Create a trigger to call the function after INSERT +CREATE TRIGGER set_timestamps_on_insert +BEFORE INSERT ON users +FOR EACH ROW +EXECUTE FUNCTION set_timestamps_on_insert(); + +-- Create a function to set updated_at on UPDATE +CREATE OR REPLACE FUNCTION set_updated_at() RETURNS TRIGGER AS $$ +BEGIN + NEW.updated_at = NOW(); + RETURN NEW; +END; +$$ LANGUAGE plpgsql; + +-- Create a trigger to call the function after UPDATE +CREATE TRIGGER set_updated_at +BEFORE UPDATE ON users +FOR EACH ROW +EXECUTE FUNCTION set_updated_at(); + +CREATE INDEX users_username_index ON users (username); \ No newline at end of file diff --git a/server/migrations_pg/0002_posts_table.sql b/server/migrations_pg/0002_posts_table.sql new file mode 100644 index 0000000..5042a86 --- /dev/null +++ b/server/migrations_pg/0002_posts_table.sql @@ -0,0 +1,43 @@ +CREATE TABLE IF NOT EXISTS posts ( + id BIGSERIAL PRIMARY KEY, + user_id BIGINT NOT NULL, + content TEXT NOT NULL, + upvotes INTEGER NOT NULL DEFAULT 0, + downvotes INTEGER NOT NULL DEFAULT 0, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (user_id) REFERENCES users (id) +); + +-- Create a function to set created_at and updated_at on INSERT +CREATE OR REPLACE FUNCTION set_timestamps_on_insert() RETURNS TRIGGER AS $$ +BEGIN + NEW.created_at = NOW(); + NEW.updated_at = NOW(); + RETURN NEW; +END; +$$ LANGUAGE plpgsql; + +-- Create a trigger to call the function after INSERT +CREATE TRIGGER set_timestamps_on_insert +BEFORE INSERT ON posts +FOR EACH ROW +EXECUTE FUNCTION set_timestamps_on_insert(); + +-- Create a function to set updated_at on UPDATE +CREATE OR REPLACE FUNCTION set_updated_at() RETURNS TRIGGER AS $$ +BEGIN + NEW.updated_at = NOW(); + RETURN NEW; +END; +$$ LANGUAGE plpgsql; + +-- Create a trigger to call the function after UPDATE +CREATE TRIGGER set_updated_at +BEFORE UPDATE ON posts +FOR EACH ROW +EXECUTE FUNCTION set_updated_at(); + +CREATE INDEX posts_user_id_index ON posts (user_id); +CREATE INDEX posts_id_index ON posts (id); +CREATE INDEX idx_created_at_desc ON posts (created_at DESC); \ No newline at end of file diff --git a/server/src/db.rs b/server/src/db.rs index aa7e33d..89c643e 100644 --- a/server/src/db.rs +++ b/server/src/db.rs @@ -4,13 +4,13 @@ use argon2::{ Argon2, PasswordHasher, PasswordVerifier, }; use log::{info, warn}; -use sqlx::SqlitePool; +use sqlx::PgPool; // Gets the latest posts from the database, ordered by created_at -pub async fn db_get_latest_posts(pool: &SqlitePool, limit: i64, offset: i64) -> Vec { +pub async fn db_get_latest_posts(pool: &PgPool, limit: i64, offset: i64) -> Vec { sqlx::query_as!( Post, - "SELECT * FROM posts ORDER BY created_at DESC LIMIT ? OFFSET ?", + "SELECT * FROM posts ORDER BY created_at DESC LIMIT $1 OFFSET $2", limit, offset ) @@ -20,19 +20,19 @@ pub async fn db_get_latest_posts(pool: &SqlitePool, limit: i64, offset: i64) -> } // Gets the post with id from the database -pub async fn db_get_post(id: i64, pool: &SqlitePool) -> Option { - sqlx::query_as!(Post, "SELECT * FROM posts WHERE id = ?", id) +pub async fn db_get_post(id: i64, pool: &PgPool) -> Option { + sqlx::query_as!(Post, "SELECT * FROM posts WHERE id = $1", id) .fetch_one(pool) .await .ok() } // Inserts a new post to the database -pub async fn db_new_post(userid: i64, content: &str, pool: &SqlitePool) -> Option { +pub async fn db_new_post(userid: i64, content: &str, pool: &PgPool) -> Option { info!("User with id {} submitted a post", userid); let insert_query = sqlx::query!( - "INSERT INTO posts (user_id, content) VALUES (?, ?)", + "INSERT INTO posts (user_id, content) VALUES ($1, $2)", userid, content ) @@ -57,8 +57,8 @@ pub async fn db_new_post(userid: i64, content: &str, pool: &SqlitePool) -> Optio Some(post) } -pub async fn db_user_exists(username: String, pool: &SqlitePool) -> bool { - let exists = sqlx::query!("SELECT username FROM users WHERE username = ?", username) +pub async fn db_user_exists(username: String, pool: &PgPool) -> bool { + let exists = sqlx::query!("SELECT username FROM users WHERE username = $1", username) .fetch_one(pool) .await .ok() @@ -67,9 +67,9 @@ pub async fn db_user_exists(username: String, pool: &SqlitePool) -> bool { exists.is_some() } -pub async fn db_user_login(username: String, password: String, pool: &SqlitePool) -> Option { +pub async fn db_user_login(username: String, password: String, pool: &PgPool) -> Option { let username = username.clone(); - let user = sqlx::query_as!(User, "SELECT * FROM users WHERE username = ?", username) + let user = sqlx::query_as!(User, "SELECT * FROM users WHERE username = $1", username) .fetch_one(pool) .await .ok()?; @@ -95,7 +95,7 @@ pub async fn db_user_login(username: String, password: String, pool: &SqlitePool } } -pub async fn db_new_user(username: String, password: String, pool: &SqlitePool) -> Option { +pub async fn db_new_user(username: String, password: String, pool: &PgPool) -> Option { // First check if the user already exists match db_user_exists(username.clone(), pool).await { true => { @@ -113,7 +113,7 @@ pub async fn db_new_user(username: String, password: String, pool: &SqlitePool) // Insert our new user into the database let insert_query = sqlx::query!( - "INSERT INTO users (username, password) VALUES (?, ?)", + "INSERT INTO users (username, password) VALUES ($1, $2)", username, phc_hash ) @@ -123,7 +123,7 @@ pub async fn db_new_user(username: String, password: String, pool: &SqlitePool) match insert_query { Ok(_) => { info!("User: {} registered", username); - let user = sqlx::query_as!(User, "SELECT * FROM users WHERE username = ?", username) + let user = sqlx::query_as!(User, "SELECT * FROM users WHERE username = $1", username) .fetch_one(pool) .await .ok()?; diff --git a/server/src/routes/post.rs b/server/src/routes/post.rs index 42ef85e..286ac56 100755 --- a/server/src/routes/post.rs +++ b/server/src/routes/post.rs @@ -79,7 +79,7 @@ pub async fn new_post(new_post: Json, state: Data) -> Resu let username = claims.sub.clone(); // This one is avoidable if we just store the user id in the token - let userid = sqlx::query!("SELECT id FROM users WHERE username = ?", username) + let userid = sqlx::query!("SELECT id FROM users WHERE username = $1", username) .fetch_one(&state.pool) .await .unwrap() diff --git a/server/src/state.rs b/server/src/state.rs index 51cda7b..adff966 100644 --- a/server/src/state.rs +++ b/server/src/state.rs @@ -4,10 +4,8 @@ use std::sync::Mutex; use log::error; use log::info; -use sqlx::migrate::MigrateDatabase; -use sqlx::Pool; -use sqlx::Sqlite; -use sqlx::{self, sqlite}; +use sqlx::postgres::PgPoolOptions; +use sqlx::PgPool; #[derive(Clone)] pub struct CaptchaState { @@ -24,7 +22,7 @@ impl CaptchaState { #[derive(Clone)] pub struct ServerState { - pub pool: Pool, + pub pool: PgPool, } impl ServerState { @@ -38,17 +36,13 @@ impl ServerState { info!("Using db_url: {}", &db_url); - if !sqlx::Sqlite::database_exists(&db_url).await.unwrap() { - sqlx::Sqlite::create_database(&db_url).await.unwrap(); - } - - let pool = sqlite::SqlitePoolOptions::new() + let pool = PgPoolOptions::new() .max_connections(5) .connect(&db_url) .await .unwrap(); - sqlx::migrate!("./migrations").run(&pool).await.unwrap(); + sqlx::migrate!("./migrations_pg").run(&pool).await.unwrap(); match crate::db::db_new_user("imbus".to_string(), "kartellen1234".to_string(), &pool).await { @@ -63,13 +57,10 @@ impl ServerState { } } -#[cfg(debug_assertions)] -use sqlx::SqlitePool; - // Inserts a bunch of dummy data into the database // Mostly useful for debugging new posts, as we need to satisfy foreign key constraints. #[cfg(debug_assertions)] -async fn debug_setup(pool: &SqlitePool) -> Result<(), sqlx::Error> { +async fn debug_setup(pool: &PgPool) -> Result<(), sqlx::Error> { use sqlx::query; use crate::db::db_new_user;