diff --git a/app.vue b/app.vue index 8b6727d..643fc86 100644 --- a/app.vue +++ b/app.vue @@ -16,4 +16,21 @@ body { a { color: aquamarine; } + +.white { + color: white; +} + +.bottom-border { + border-bottom: 1px solid rgb(70, 70, 70); +} + +.left-border { + border-left: 1px solid rgb(70, 70, 70); +} + +.right-border { + border-right: 1px solid rgb(70, 70, 70); +} + diff --git a/assets/img/check-mark.png b/assets/img/check-mark.png deleted file mode 100644 index 597c805..0000000 Binary files a/assets/img/check-mark.png and /dev/null differ diff --git a/assets/img/check-mark.svg b/assets/img/check-mark.svg deleted file mode 100644 index c419bf2..0000000 --- a/assets/img/check-mark.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/img/envelope.svg b/assets/img/envelope.svg deleted file mode 100644 index 00b5edd..0000000 --- a/assets/img/envelope.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/img/house.svg b/assets/img/house.svg deleted file mode 100644 index ad84b18..0000000 --- a/assets/img/house.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/img/server.svg b/assets/img/server.svg deleted file mode 100644 index 56d54fc..0000000 --- a/assets/img/server.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/assets/img/tiger-head.svg b/assets/img/tiger-head.svg deleted file mode 100644 index dd68658..0000000 --- a/assets/img/tiger-head.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/classes/Message.ts b/classes/Message.ts new file mode 100644 index 0000000..de0d12b --- /dev/null +++ b/classes/Message.ts @@ -0,0 +1,19 @@ +import type { MessageResponse } from "~/types/interfaces"; + +export default class Message { + uuid: string; + channelUuid: string; + userUuid: string; + message: string; + + constructor({ uuid, channel_uuid, user_uuid, message }: MessageResponse) { + this.uuid = uuid; + this.channelUuid = channel_uuid; + this.userUuid = user_uuid; + this.message = message; + } + + getTimestamp() { + return uuidToTimestamp(this.uuid); + } +} \ No newline at end of file diff --git a/components/Channel.vue b/components/Channel.vue index 0f06528..a0cdc78 100644 --- a/components/Channel.vue +++ b/components/Channel.vue @@ -1,14 +1,19 @@ @@ -16,5 +21,18 @@ const props = defineProps<{ name: string, href: string }>(); .channel-list-link { text-decoration: none; color: inherit; + padding-left: .5dvw; + padding-right: .5dvw; +} + +.channel-list-link-container { + text-align: left; + display: flex; + height: 4dvh; + white-space: nowrap; +} + +.current-channel { + background-color: rgb(70, 70, 70); } \ No newline at end of file diff --git a/components/InvitePopup.vue b/components/InvitePopup.vue new file mode 100644 index 0000000..ee6f124 --- /dev/null +++ b/components/InvitePopup.vue @@ -0,0 +1,40 @@ + + + + + \ No newline at end of file diff --git a/components/Loading.vue b/components/Loading.vue new file mode 100644 index 0000000..14a379d --- /dev/null +++ b/components/Loading.vue @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/components/Message.vue b/components/Message.vue index 44dc983..870738b 100644 --- a/components/Message.vue +++ b/components/Message.vue @@ -1,13 +1,20 @@ @@ -57,8 +51,6 @@ const form = reactive({ repeatPassword: "" }); -const response = ref(); - /* const errorMessages = reactive({ username: { @@ -81,18 +73,11 @@ const errorMessages = reactive({ */ //const authStore = useAuthStore(); -const accessToken = useCookie("access_token"); -const refreshToken = useCookie("refresh_token"); +const auth = useAuth(); const redirectTo = useRoute().query.redirect_to; -console.log("access token:", accessToken.value); -console.log("refresh token:", refreshToken.value); - onMounted(() => { - console.log("accessToken:", accessToken.value); - console.log("refreshToken:", refreshToken.value); - - if (accessToken.value) { + if (auth.accessToken.value) { //return navigateTo(redirectTo ? redirectTo as string : useAppConfig().baseURL as string); } }); @@ -135,19 +120,7 @@ const apiVersion = useRuntimeConfig().public.apiVersion; async function register(e: Event) { e.preventDefault(); console.log("Sending registration data"); - const hashedPass = await hashPassword(form.password); - const res = await $fetch(`/api/v${apiVersion}/auth/register`, { - method: "POST", body: - { - email: form.email, username: form.username, password: hashedPass - } - }) as { access_token: string, refresh_token: string }; - response.value = res; - //authStore.setAccessToken(accessToken); - accessToken.value = res.access_token; - console.log("set access token:", accessToken.value); - const refreshToken = useCookie("refresh_token", { secure: true, httpOnly: false }); - refreshToken.value = res.refresh_token; + await auth.register(form.username, form.email, form.password); //return navigateTo(redirectTo ? redirectTo as string : useAppConfig().baseURL as string); } diff --git a/pages/servers/[serverId]/channels/[channelId].vue b/pages/servers/[serverId]/channels/[channelId].vue index b9b4da4..2954af9 100644 --- a/pages/servers/[serverId]/channels/[channelId].vue +++ b/pages/servers/[serverId]/channels/[channelId].vue @@ -1,13 +1,144 @@ \ No newline at end of file diff --git a/pages/servers/[serverId]/index.vue b/pages/servers/[serverId]/index.vue index b9b4da4..b45982a 100644 --- a/pages/servers/[serverId]/index.vue +++ b/pages/servers/[serverId]/index.vue @@ -1,10 +1,12 @@ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d78b130..4d4de9d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@nuxt/eslint': specifier: ^1.3.0 version: 1.3.0(@vue/compiler-sfc@3.5.13)(eslint@9.25.1(jiti@2.4.2))(magicast@0.3.5)(typescript@5.8.3)(vite@6.3.3(@types/node@22.15.3)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.1)) + '@nuxt/icon': + specifier: 1.13.0 + version: 1.13.0(magicast@0.3.5)(vite@6.3.3(@types/node@22.15.3)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.1))(vue@3.5.13(typescript@5.8.3)) '@nuxt/image': specifier: 1.10.0 version: 1.10.0(@netlify/blobs@8.2.0)(db0@0.3.2)(ioredis@5.6.1)(magicast@0.3.5) @@ -36,6 +39,9 @@ importers: specifier: ^4.5.1 version: 4.5.1(vue@3.5.13(typescript@5.8.3)) devDependencies: + '@iconify-json/lucide': + specifier: ^1.2.44 + version: 1.2.44 '@types/node': specifier: ^22.15.3 version: 22.15.3 @@ -55,6 +61,9 @@ packages: '@antfu/install-pkg@1.0.0': resolution: {integrity: sha512-xvX6P/lo1B3ej0OsaErAjqgFYzYVcJpamjLAFLYh9vRJngBrMoUG7aVnrGTeqM7yxbyTD5p3F2+0/QUEh8Vzhw==} + '@antfu/utils@8.1.1': + resolution: {integrity: sha512-Mex9nXf9vR6AhcXmMrlz/HVgYYZpVGJ6YlPgwl7UnaFpnshXs6EK/oa5Gpf3CzENMjkvEx2tQtntGnb7UtSTOQ==} + '@apidevtools/json-schema-ref-parser@11.9.3': resolution: {integrity: sha512-60vepv88RwcJtSHrD6MjIL6Ta3SOYbgfnkHb+ppAVK+o9mXprRtulx7VlRl3lN3bbvysAfCS7WMVfhUYemB0IQ==} engines: {node: '>= 16'} @@ -578,6 +587,23 @@ packages: resolution: {integrity: sha512-xeO57FpIu4p1Ri3Jq/EXq4ClRm86dVF2z/+kvFnyqVYRavTZmaFaUBbWCOuuTh0o/g7DSsk6kc2vrS4Vl5oPOQ==} engines: {node: '>=18.18'} + '@iconify-json/lucide@1.2.44': + resolution: {integrity: sha512-lOwXoOtkFm4Zj1duPj5xqhPKKMUvxVRMfIHi0YDfwLjEEgrhzsJZ4JCpE119L8P8p6zi4on4b9cPZdVXCUuDoQ==} + + '@iconify/collections@1.0.551': + resolution: {integrity: sha512-5Jy+BoI4nsNE1nHqukQh5ZxxppGThyU3VR794PLmZtbF7YJGYYa4SETnGRl4hz/5lKiTe8OhlXf5Ns45ZGLz5w==} + + '@iconify/types@2.0.0': + resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} + + '@iconify/utils@2.3.0': + resolution: {integrity: sha512-GmQ78prtwYW6EtzXRU1rY+KwOKfz32PD7iJh6Iyqw68GiKuoZ2A6pRtzWONz5VQJbp50mEjXh/7NkumtrAgRKA==} + + '@iconify/vue@5.0.0': + resolution: {integrity: sha512-C+KuEWIF5nSBrobFJhT//JS87OZ++QDORB6f2q2Wm6fl2mueSTpFBeBsveK0KW9hWiZ4mNiPjsh6Zs4jjdROSg==} + peerDependencies: + vue: '>=3' + '@ioredis/commands@1.2.0': resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==} @@ -704,6 +730,11 @@ packages: peerDependencies: vite: '>=6.0' + '@nuxt/devtools-kit@2.4.1': + resolution: {integrity: sha512-taA2Nm03JiV3I+SEYS/u1AfjvLm3V9PO8lh0xLsUk/2mlUnL6GZ9xLXrp8VRg11HHt7EPXERGQh8h4iSPU2bSQ==} + peerDependencies: + vite: '>=6.0' + '@nuxt/devtools-wizard@2.4.0': resolution: {integrity: sha512-3/5S2zpl79rE1b/lh8M/2lDNsYiYIXXHZmCwsYPuFJA6DilLQo/VY44oq6cY0Q1up32HYB3h1Te/q3ELbsb+ag==} hasBin: true @@ -740,6 +771,9 @@ packages: vite-plugin-eslint2: optional: true + '@nuxt/icon@1.13.0': + resolution: {integrity: sha512-Sft1DZj/U5Up60DMnhp+hRDNDXRkMhwHocxgDkDkAPBxqR8PRyvzxcMIy3rjGMu0s+fB6ZdLs6vtaWzjWuerQQ==} + '@nuxt/image@1.10.0': resolution: {integrity: sha512-/B58GeEmme7bkmQUrXzEw8P9sJb9BkMaYZqLDtq8ZdDLEddE3P4nVya8RQPB+p4b7EdqWajpPqdy1A2ZPLev/A==} engines: {node: '>=18.20.6'} @@ -748,10 +782,18 @@ packages: resolution: {integrity: sha512-+aS+Enqqo2qSbyl0APPPxX8BPYsaRcZ8dFRbpCOfK38lv2ckoHKCWNkT8L/7q2w+1pjNZaxlUoW9Mku1vdEb/A==} engines: {node: '>=18.12.0'} + '@nuxt/kit@3.17.4': + resolution: {integrity: sha512-l+hY8sy2XFfg3PigZj+PTu6+KIJzmbACTRimn1ew/gtCz+F38f6KTF4sMRTN5CUxiB8TRENgEonASmkAWfpO9Q==} + engines: {node: '>=18.12.0'} + '@nuxt/schema@3.17.0': resolution: {integrity: sha512-BwHD1NBtZRlk+qPZYvNzzdp7MG8s4i5gmTQ+12hbxc9x09osB9RivAU2ekwMMLfykx90wDszDu0DJ5Zec4Svgg==} engines: {node: ^14.18.0 || >=16.10.0} + '@nuxt/schema@3.17.4': + resolution: {integrity: sha512-bsfJdWjKNYLkVQt7Ykr9YsAql1u8Tuo6iecSUOltTIhsvAIYsknRFPHoNKNmaiv/L6FgCQgUgQppPTPUAXiJQQ==} + engines: {node: ^14.18.0 || >=16.10.0} + '@nuxt/telemetry@2.6.6': resolution: {integrity: sha512-Zh4HJLjzvm3Cq9w6sfzIFyH9ozK5ePYVfCUzzUQNiZojFsI2k1QkSBrVI9BGc6ArKXj/O6rkI6w7qQ+ouL8Cag==} engines: {node: '>=18.12.0'} @@ -1409,6 +1451,9 @@ packages: '@vue/shared@3.5.13': resolution: {integrity: sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==} + '@vue/shared@3.5.14': + resolution: {integrity: sha512-oXTwNxVfc9EtP1zzXAlSlgARLXNC84frFYkS0HHz0h3E4WZSP9sywqjqzGCP9Y34M8ipNmd380pVgmMuwELDyQ==} + '@whatwg-node/disposablestack@0.0.6': resolution: {integrity: sha512-LOtTn+JgJvX8WfBVJtF08TGrdjuFzGJc4mkP8EdDI8ADbvO7kiexYep1o8dwnt0okb0jYclCDXF13xU7Ge4zSw==} engines: {node: '>=18.0.0'} @@ -1650,6 +1695,14 @@ packages: magicast: optional: true + c12@3.0.4: + resolution: {integrity: sha512-t5FaZTYbbCtvxuZq9xxIruYydrAGsJ+8UdP0pZzMiK2xl/gNiSOy0OxhLzHUEEb0m1QXYqfzfvyIFEmz/g9lqg==} + peerDependencies: + magicast: ^0.3.5 + peerDependenciesMeta: + magicast: + optional: true + cac@6.7.14: resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} engines: {node: '>=8'} @@ -2546,6 +2599,10 @@ packages: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} + globals@15.15.0: + resolution: {integrity: sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==} + engines: {node: '>=18'} + globals@16.0.0: resolution: {integrity: sha512-iInW14XItCXET01CQFqudPOWP2jYMl7T+QRQT+UNcR/iQncN/F0UNpgd76iFkBPgNQb4+X3LV9tLJYzwh+Gl3A==} engines: {node: '>=18'} @@ -2873,6 +2930,9 @@ packages: knitwork@1.2.0: resolution: {integrity: sha512-xYSH7AvuQ6nXkq42x0v5S8/Iry+cfulBz/DJQzhIyESdLD7425jXsPy4vn5cCXU+HhRN2kVw51Vd1K6/By4BQg==} + kolorist@1.8.0: + resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==} + kuler@2.0.0: resolution: {integrity: sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==} @@ -3917,6 +3977,11 @@ packages: engines: {node: '>=10'} hasBin: true + semver@7.7.2: + resolution: {integrity: sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==} + engines: {node: '>=10'} + hasBin: true + send@1.2.0: resolution: {integrity: sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==} engines: {node: '>= 18'} @@ -4287,6 +4352,10 @@ packages: resolution: {integrity: sha512-8jL3T+FKDg+qLFX55X9j92uFRqH5vWrNlf/eJb5IQlQB5q5wjooXQDXP1ulhJJQHbosBmlKhBo/ZVS5jHlcJGA==} engines: {node: '>=18.12.0'} + unimport@5.0.1: + resolution: {integrity: sha512-1YWzPj6wYhtwHE+9LxRlyqP4DiRrhGfJxdtH475im8ktyZXO3jHj/3PZ97zDdvkYoovFdi0K4SKl3a7l92v3sQ==} + engines: {node: '>=18.12.0'} + unixify@1.0.0: resolution: {integrity: sha512-6bc58dPYhCMHHuwxldQxO3RRNZ4eCogZ/st++0+fcC1nr0jiGUtAdBJ2qzmLQWSxbtz42pWt4QQMiZ9HvZf5cg==} engines: {node: '>=0.10.0'} @@ -4684,6 +4753,8 @@ snapshots: package-manager-detector: 0.2.11 tinyexec: 0.3.2 + '@antfu/utils@8.1.1': {} + '@apidevtools/json-schema-ref-parser@11.9.3': dependencies: '@jsdevtools/ono': 7.1.3 @@ -5143,6 +5214,34 @@ snapshots: '@humanwhocodes/retry@0.4.2': {} + '@iconify-json/lucide@1.2.44': + dependencies: + '@iconify/types': 2.0.0 + + '@iconify/collections@1.0.551': + dependencies: + '@iconify/types': 2.0.0 + + '@iconify/types@2.0.0': {} + + '@iconify/utils@2.3.0': + dependencies: + '@antfu/install-pkg': 1.0.0 + '@antfu/utils': 8.1.1 + '@iconify/types': 2.0.0 + debug: 4.4.0 + globals: 15.15.0 + kolorist: 1.8.0 + local-pkg: 1.1.1 + mlly: 1.7.4 + transitivePeerDependencies: + - supports-color + + '@iconify/vue@5.0.0(vue@3.5.13(typescript@5.8.3))': + dependencies: + '@iconify/types': 2.0.0 + vue: 3.5.13(typescript@5.8.3) + '@ioredis/commands@1.2.0': {} '@isaacs/cliui@8.0.2': @@ -5377,6 +5476,15 @@ snapshots: transitivePeerDependencies: - magicast + '@nuxt/devtools-kit@2.4.1(magicast@0.3.5)(vite@6.3.3(@types/node@22.15.3)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.1))': + dependencies: + '@nuxt/kit': 3.17.4(magicast@0.3.5) + '@nuxt/schema': 3.17.4 + execa: 8.0.1 + vite: 6.3.3(@types/node@22.15.3)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.1) + transitivePeerDependencies: + - magicast + '@nuxt/devtools-wizard@2.4.0': dependencies: consola: 3.4.2 @@ -5492,6 +5600,28 @@ snapshots: - utf-8-validate - vite + '@nuxt/icon@1.13.0(magicast@0.3.5)(vite@6.3.3(@types/node@22.15.3)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.1))(vue@3.5.13(typescript@5.8.3))': + dependencies: + '@iconify/collections': 1.0.551 + '@iconify/types': 2.0.0 + '@iconify/utils': 2.3.0 + '@iconify/vue': 5.0.0(vue@3.5.13(typescript@5.8.3)) + '@nuxt/devtools-kit': 2.4.1(magicast@0.3.5)(vite@6.3.3(@types/node@22.15.3)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.1)) + '@nuxt/kit': 3.17.4(magicast@0.3.5) + consola: 3.4.2 + local-pkg: 1.1.1 + mlly: 1.7.4 + ohash: 2.0.11 + pathe: 2.0.3 + picomatch: 4.0.2 + std-env: 3.9.0 + tinyglobby: 0.2.13 + transitivePeerDependencies: + - magicast + - supports-color + - vite + - vue + '@nuxt/image@1.10.0(@netlify/blobs@8.2.0)(db0@0.3.2)(ioredis@5.6.1)(magicast@0.3.5)': dependencies: '@nuxt/kit': 3.17.0(magicast@0.3.5) @@ -5555,6 +5685,33 @@ snapshots: transitivePeerDependencies: - magicast + '@nuxt/kit@3.17.4(magicast@0.3.5)': + dependencies: + c12: 3.0.4(magicast@0.3.5) + consola: 3.4.2 + defu: 6.1.4 + destr: 2.0.5 + errx: 0.1.0 + exsolve: 1.0.5 + ignore: 7.0.4 + jiti: 2.4.2 + klona: 2.0.6 + knitwork: 1.2.0 + mlly: 1.7.4 + ohash: 2.0.11 + pathe: 2.0.3 + pkg-types: 2.1.0 + scule: 1.3.0 + semver: 7.7.2 + std-env: 3.9.0 + tinyglobby: 0.2.13 + ufo: 1.6.1 + unctx: 2.4.1 + unimport: 5.0.1 + untyped: 2.0.0 + transitivePeerDependencies: + - magicast + '@nuxt/schema@3.17.0': dependencies: consola: 3.4.2 @@ -5562,6 +5719,14 @@ snapshots: pathe: 2.0.3 std-env: 3.9.0 + '@nuxt/schema@3.17.4': + dependencies: + '@vue/shared': 3.5.14 + consola: 3.4.2 + defu: 6.1.4 + pathe: 2.0.3 + std-env: 3.9.0 + '@nuxt/telemetry@2.6.6(magicast@0.3.5)': dependencies: '@nuxt/kit': 3.17.0(magicast@0.3.5) @@ -6270,6 +6435,8 @@ snapshots: '@vue/shared@3.5.13': {} + '@vue/shared@3.5.14': {} + '@whatwg-node/disposablestack@0.0.6': dependencies: '@whatwg-node/promise-helpers': 1.3.1 @@ -6520,6 +6687,23 @@ snapshots: optionalDependencies: magicast: 0.3.5 + c12@3.0.4(magicast@0.3.5): + dependencies: + chokidar: 4.0.3 + confbox: 0.2.2 + defu: 6.1.4 + dotenv: 16.5.0 + exsolve: 1.0.5 + giget: 2.0.0 + jiti: 2.4.2 + ohash: 2.0.11 + pathe: 2.0.3 + perfect-debounce: 1.0.0 + pkg-types: 2.1.0 + rc9: 2.1.2 + optionalDependencies: + magicast: 0.3.5 + cac@6.7.14: {} call-bind-apply-helpers@1.0.2: @@ -7505,6 +7689,8 @@ snapshots: globals@14.0.0: {} + globals@15.15.0: {} + globals@16.0.0: {} globby@11.1.0: @@ -7824,6 +8010,8 @@ snapshots: knitwork@1.2.0: {} + kolorist@1.8.0: {} + kuler@2.0.0: {} lambda-local@2.2.0: @@ -9030,6 +9218,8 @@ snapshots: semver@7.7.1: {} + semver@7.7.2: {} + send@1.2.0: dependencies: debug: 4.4.0 @@ -9475,6 +9665,23 @@ snapshots: unplugin: 2.3.2 unplugin-utils: 0.2.4 + unimport@5.0.1: + dependencies: + acorn: 8.14.1 + escape-string-regexp: 5.0.0 + estree-walker: 3.0.3 + local-pkg: 1.1.1 + magic-string: 0.30.17 + mlly: 1.7.4 + pathe: 2.0.3 + picomatch: 4.0.2 + pkg-types: 2.1.0 + scule: 1.3.0 + strip-literal: 3.0.0 + tinyglobby: 0.2.13 + unplugin: 2.3.2 + unplugin-utils: 0.2.4 + unixify@1.0.0: dependencies: normalize-path: 2.1.1 diff --git a/types.d.ts b/types.d.ts new file mode 100644 index 0000000..1ed1ce8 --- /dev/null +++ b/types.d.ts @@ -0,0 +1,6 @@ +export interface GorbStats { + accounts: number, + uptime: number, + version: string, + build_number: string +} \ No newline at end of file diff --git a/types/interfaces.ts b/types/interfaces.ts new file mode 100644 index 0000000..05830d2 --- /dev/null +++ b/types/interfaces.ts @@ -0,0 +1,54 @@ +export interface ChannelPermissionResponse { + channel_uuid: string, + role_uuid: string, + permissions: number +} + +export interface RoleResponse { + uuid: string, + guild_uuid: string, + name: string, + color: number, + position: number, + permissions: number +} + +export interface GuildResponse { + uuid: string, + name: string, + description: string | null, + icon: string | null, + owner_uuid: string, + roles: [], + member_count: number +} + +export interface ChannelResponse { + uuid: string, + guild_uuid: string, + name: string, + description: string, + permissions: ChannelPermissionResponse[] +} + +export interface MessageResponse { + uuid: string + channel_uuid: string + user_uuid: string + message: string +} + +export interface InviteResponse { + id: string, + user_uuid: string, + guild_uuid: string +} + +export interface UserResponse { + uuid: string, + username: string, + display_name: string | null, + avatar: string | null, + email: string, + email_verified: boolean + } diff --git a/utils/fetchWithApi.ts b/utils/fetchWithApi.ts new file mode 100644 index 0000000..c0ebf2e --- /dev/null +++ b/utils/fetchWithApi.ts @@ -0,0 +1,71 @@ +import type { NitroFetchRequest, NitroFetchOptions } from "nitropack"; + +export default async (path: string, options: NitroFetchOptions = {}) => { + console.log("path received:", path); + if (!path.startsWith("/")) { + path = "/" + path; + } + if (path.endsWith("/")) { + path = path.slice(0, path.lastIndexOf("/")); + } + console.log("formatted path:", path); + try { + const accessToken = useCookie("access_token"); + console.log("access token:", accessToken.value); + const apiBase = useCookie("api_base").value; + const apiVersion = useRuntimeConfig().public.apiVersion; + console.log("heyoooo") + console.log("apiBase:", apiBase); + if (!apiBase) { + console.log("no api base"); + return; + } + console.log("path:", path) + const { revoke, refresh } = useAuth(); + console.log("access token 2:", accessToken.value); + + let headers: HeadersInit = {}; + + if (accessToken.value) { + headers = { + ...options.headers, + "Authorization": `Bearer ${accessToken.value}` + }; + } else { + headers = { + ...options.headers + }; + } + + let reauthFailed = false; + while (!reauthFailed) { + try { + console.log("fetching:", URL.parse(apiBase + path)); + const res = await $fetch(URL.parse(apiBase + path)!.href, { + ...options, + headers, + credentials: "include" + }); + + return res; + } catch (error: any) { + if (error?.response?.status === 401) { + if (!path.startsWith("/auth/refresh")) { + try { + await refresh(); + } catch (error: any) { + if (error?.response?.status === 401) { + reauthFailed = true; + await revoke(); + return; + } + } + } + } + throw error; + } + } + } catch (error) { + console.error("error:", error); + } +} diff --git a/utils/sleep.ts b/utils/sleep.ts new file mode 100644 index 0000000..b4ef59b --- /dev/null +++ b/utils/sleep.ts @@ -0,0 +1,3 @@ +export default async (ms: number): Promise => { + return new Promise(resolve => setTimeout(resolve, ms)); +} diff --git a/utils/uuidToTimestamp.ts b/utils/uuidToTimestamp.ts new file mode 100644 index 0000000..78d6b12 --- /dev/null +++ b/utils/uuidToTimestamp.ts @@ -0,0 +1,6 @@ +export default (uuid: string) => { + const parts = uuid.split("-"); + const bits = parts[0] + parts[1].slice(0, 4); + const timestamp = parseInt(bits, 16); + return timestamp; +}