diff --git a/server-api/.env b/json-api/.env similarity index 100% rename from server-api/.env rename to json-api/.env diff --git a/server-api/.gitignore b/json-api/.gitignore similarity index 100% rename from server-api/.gitignore rename to json-api/.gitignore diff --git a/json-api/.vscode/launch.json b/json-api/.vscode/launch.json new file mode 100644 index 0000000..321e59e --- /dev/null +++ b/json-api/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Client Tests", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/client-tests/client.py", + "console": "integratedTerminal" + }, + { + "type": "lldb", + "request": "launch", + "name": "(Linux) Debug", + "program": "${workspaceFolder}/target/debug/freechat-server", + "args": [ + "-s" + ], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/server-api/.vscode/settings.json b/json-api/.vscode/settings.json similarity index 100% rename from server-api/.vscode/settings.json rename to json-api/.vscode/settings.json diff --git a/server-api/Cargo.lock b/json-api/Cargo.lock similarity index 100% rename from server-api/Cargo.lock rename to json-api/Cargo.lock diff --git a/server-api/Cargo.toml b/json-api/Cargo.toml similarity index 92% rename from server-api/Cargo.toml rename to json-api/Cargo.toml index 9e79311..3de2876 100644 --- a/server-api/Cargo.toml +++ b/json-api/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "freechat-server" -version = "0.1.0" +name = "json-api" +version = "0.2.0" authors = ["shockrah "] edition = "2018" diff --git a/server-api/build.sh b/json-api/build.sh similarity index 100% rename from server-api/build.sh rename to json-api/build.sh diff --git a/server-api/client-tests/.gitignore b/json-api/client-tests/.gitignore similarity index 100% rename from server-api/client-tests/.gitignore rename to json-api/client-tests/.gitignore diff --git a/server-api/client-tests/__init__.py b/json-api/client-tests/__init__.py similarity index 100% rename from server-api/client-tests/__init__.py rename to json-api/client-tests/__init__.py diff --git a/server-api/client-tests/client.py b/json-api/client-tests/client.py similarity index 100% rename from server-api/client-tests/client.py rename to json-api/client-tests/client.py diff --git a/server-api/client-tests/pyvenv.cfg b/json-api/client-tests/pyvenv.cfg similarity index 100% rename from server-api/client-tests/pyvenv.cfg rename to json-api/client-tests/pyvenv.cfg diff --git a/server-api/client-tests/requirements.txt b/json-api/client-tests/requirements.txt similarity index 100% rename from server-api/client-tests/requirements.txt rename to json-api/client-tests/requirements.txt diff --git a/server-api/client-tests/web/__init__.py b/json-api/client-tests/web/__init__.py similarity index 100% rename from server-api/client-tests/web/__init__.py rename to json-api/client-tests/web/__init__.py diff --git a/server-api/client-tests/web/http.py b/json-api/client-tests/web/http.py similarity index 100% rename from server-api/client-tests/web/http.py rename to json-api/client-tests/web/http.py diff --git a/server-api/db/Cargo.lock b/json-api/db/Cargo.lock similarity index 100% rename from server-api/db/Cargo.lock rename to json-api/db/Cargo.lock diff --git a/server-api/db/Cargo.toml b/json-api/db/Cargo.toml similarity index 100% rename from server-api/db/Cargo.toml rename to json-api/db/Cargo.toml diff --git a/server-api/db/src/auth.rs b/json-api/db/src/auth.rs similarity index 100% rename from server-api/db/src/auth.rs rename to json-api/db/src/auth.rs diff --git a/server-api/db/src/channels.rs b/json-api/db/src/channels.rs similarity index 100% rename from server-api/db/src/channels.rs rename to json-api/db/src/channels.rs diff --git a/server-api/db/src/common.rs b/json-api/db/src/common.rs similarity index 100% rename from server-api/db/src/common.rs rename to json-api/db/src/common.rs diff --git a/server-api/db/src/invites.rs b/json-api/db/src/invites.rs similarity index 100% rename from server-api/db/src/invites.rs rename to json-api/db/src/invites.rs diff --git a/server-api/db/src/lib.rs b/json-api/db/src/lib.rs similarity index 100% rename from server-api/db/src/lib.rs rename to json-api/db/src/lib.rs diff --git a/server-api/db/src/member.rs b/json-api/db/src/member.rs similarity index 100% rename from server-api/db/src/member.rs rename to json-api/db/src/member.rs diff --git a/server-api/db/src/messages.rs b/json-api/db/src/messages.rs similarity index 100% rename from server-api/db/src/messages.rs rename to json-api/db/src/messages.rs diff --git a/server-api/endpoints.md b/json-api/endpoints.md similarity index 100% rename from server-api/endpoints.md rename to json-api/endpoints.md diff --git a/json-api/hmac.secret b/json-api/hmac.secret new file mode 100644 index 0000000..507cee7 --- /dev/null +++ b/json-api/hmac.secret @@ -0,0 +1,2 @@ +bC'BI%bj]H>$ bwY攘# +4O>'ɓ \ No newline at end of file diff --git a/server-api/migrations/.gitkeep b/json-api/migrations/.gitkeep similarity index 100% rename from server-api/migrations/.gitkeep rename to json-api/migrations/.gitkeep diff --git a/server-api/migrations/2020-02-04-083657_invites/down.sql b/json-api/migrations/2020-02-04-083657_invites/down.sql similarity index 100% rename from server-api/migrations/2020-02-04-083657_invites/down.sql rename to json-api/migrations/2020-02-04-083657_invites/down.sql diff --git a/server-api/migrations/2020-02-04-083657_invites/up.sql b/json-api/migrations/2020-02-04-083657_invites/up.sql similarity index 100% rename from server-api/migrations/2020-02-04-083657_invites/up.sql rename to json-api/migrations/2020-02-04-083657_invites/up.sql diff --git a/server-api/migrations/2020-03-11-005217_channels/down.sql b/json-api/migrations/2020-03-11-005217_channels/down.sql similarity index 100% rename from server-api/migrations/2020-03-11-005217_channels/down.sql rename to json-api/migrations/2020-03-11-005217_channels/down.sql diff --git a/server-api/migrations/2020-03-11-005217_channels/up.sql b/json-api/migrations/2020-03-11-005217_channels/up.sql similarity index 100% rename from server-api/migrations/2020-03-11-005217_channels/up.sql rename to json-api/migrations/2020-03-11-005217_channels/up.sql diff --git a/server-api/migrations/2020-07-05-215114_members/down.sql b/json-api/migrations/2020-07-05-215114_members/down.sql similarity index 100% rename from server-api/migrations/2020-07-05-215114_members/down.sql rename to json-api/migrations/2020-07-05-215114_members/down.sql diff --git a/server-api/migrations/2020-07-05-215114_members/up.sql b/json-api/migrations/2020-07-05-215114_members/up.sql similarity index 100% rename from server-api/migrations/2020-07-05-215114_members/up.sql rename to json-api/migrations/2020-07-05-215114_members/up.sql diff --git a/server-api/migrations/2020-07-06-022319_messages/down.sql b/json-api/migrations/2020-07-06-022319_messages/down.sql similarity index 100% rename from server-api/migrations/2020-07-06-022319_messages/down.sql rename to json-api/migrations/2020-07-06-022319_messages/down.sql diff --git a/server-api/migrations/2020-07-06-022319_messages/up.sql b/json-api/migrations/2020-07-06-022319_messages/up.sql similarity index 100% rename from server-api/migrations/2020-07-06-022319_messages/up.sql rename to json-api/migrations/2020-07-06-022319_messages/up.sql diff --git a/server-api/migrations/2020-12-29-030934_jwt/down.sql b/json-api/migrations/2020-12-29-030934_jwt/down.sql similarity index 100% rename from server-api/migrations/2020-12-29-030934_jwt/down.sql rename to json-api/migrations/2020-12-29-030934_jwt/down.sql diff --git a/server-api/migrations/2020-12-29-030934_jwt/up.sql b/json-api/migrations/2020-12-29-030934_jwt/up.sql similarity index 100% rename from server-api/migrations/2020-12-29-030934_jwt/up.sql rename to json-api/migrations/2020-12-29-030934_jwt/up.sql diff --git a/server-api/scripts/generate-hmac.sh b/json-api/scripts/generate-hmac.sh similarity index 100% rename from server-api/scripts/generate-hmac.sh rename to json-api/scripts/generate-hmac.sh diff --git a/server-api/scripts/setup-dev-user.sh b/json-api/scripts/setup-dev-user.sh similarity index 100% rename from server-api/scripts/setup-dev-user.sh rename to json-api/scripts/setup-dev-user.sh diff --git a/server-api/src/admin.rs b/json-api/src/admin.rs similarity index 100% rename from server-api/src/admin.rs rename to json-api/src/admin.rs diff --git a/server-api/src/auth.rs b/json-api/src/auth.rs similarity index 100% rename from server-api/src/auth.rs rename to json-api/src/auth.rs diff --git a/server-api/src/channels.rs b/json-api/src/channels.rs similarity index 100% rename from server-api/src/channels.rs rename to json-api/src/channels.rs diff --git a/server-api/src/http.rs b/json-api/src/http.rs similarity index 100% rename from server-api/src/http.rs rename to json-api/src/http.rs diff --git a/server-api/src/http_params.rs b/json-api/src/http_params.rs similarity index 100% rename from server-api/src/http_params.rs rename to json-api/src/http_params.rs diff --git a/server-api/src/invites.rs b/json-api/src/invites.rs similarity index 100% rename from server-api/src/invites.rs rename to json-api/src/invites.rs diff --git a/server-api/src/main.rs b/json-api/src/main.rs similarity index 100% rename from server-api/src/main.rs rename to json-api/src/main.rs diff --git a/server-api/src/members.rs b/json-api/src/members.rs similarity index 100% rename from server-api/src/members.rs rename to json-api/src/members.rs diff --git a/server-api/src/messages.rs b/json-api/src/messages.rs similarity index 100% rename from server-api/src/messages.rs rename to json-api/src/messages.rs diff --git a/server-api/src/meta.rs b/json-api/src/meta.rs similarity index 100% rename from server-api/src/meta.rs rename to json-api/src/meta.rs diff --git a/server-api/src/perms.rs b/json-api/src/perms.rs similarity index 100% rename from server-api/src/perms.rs rename to json-api/src/perms.rs diff --git a/server-api/src/routes.rs b/json-api/src/routes.rs similarity index 100% rename from server-api/src/routes.rs rename to json-api/src/routes.rs diff --git a/json-api/src/schema.rs b/json-api/src/schema.rs new file mode 100644 index 0000000..b9d5165 --- /dev/null +++ b/json-api/src/schema.rs @@ -0,0 +1,54 @@ +table! { + channels (id) { + id -> Unsigned, + name -> Varchar, + description -> Nullable, + kind -> Integer, + } +} + +table! { + invites (id) { + id -> Bigint, + uses -> Nullable, + expires -> Bool, + } +} + +table! { + jwt (id) { + id -> Unsigned, + token -> Varchar, + } +} + +table! { + members (id, secret) { + id -> Unsigned, + secret -> Varchar, + name -> Varchar, + joindate -> Bigint, + status -> Integer, + permissions -> Unsigned, + } +} + +table! { + messages (id) { + id -> Unsigned, + time -> Bigint, + content -> Varchar, + author_id -> Unsigned, + channel_id -> Unsigned, + } +} + +joinable!(messages -> channels (channel_id)); + +allow_tables_to_appear_in_same_query!( + channels, + invites, + jwt, + members, + messages, +); diff --git a/server-api/src/testing/mod.rs b/json-api/src/testing/mod.rs similarity index 100% rename from server-api/src/testing/mod.rs rename to json-api/src/testing/mod.rs