From 69f20b6393628892e1b0888e8152b458556ebe42 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Wed, 1 May 2024 23:58:33 +0200 Subject: [PATCH] add register functionality --- Cargo.toml | 2 + kitsune-fe/houdini.config.js | 5 + kitsune-fe/schema.graphql | 226 +++++++++++++++++------------ kitsune-fe/src/client.ts | 2 +- kitsune-fe/src/routes/+page.svelte | 67 ++++++++- 5 files changed, 203 insertions(+), 99 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3854a05a6..9f2cfbc43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,6 @@ [profile.dev.package] +backtrace = { opt-level = 3 } +num-bigint-dig = { opt-level = 3 } taplo = { debug-assertions = false } # A debug assertion will make the xtask panic with too long trailing comments # The profile that 'cargo dist' will build with diff --git a/kitsune-fe/houdini.config.js b/kitsune-fe/houdini.config.js index 2de8a62e0..42b3c1847 100644 --- a/kitsune-fe/houdini.config.js +++ b/kitsune-fe/houdini.config.js @@ -7,6 +7,11 @@ const config = { }, plugins: { 'houdini-svelte': {} + }, + scalars: { + DateTime: { + type: 'Date' + } } }; diff --git a/kitsune-fe/schema.graphql b/kitsune-fe/schema.graphql index fec7c002c..1b0b60890 100644 --- a/kitsune-fe/schema.graphql +++ b/kitsune-fe/schema.graphql @@ -1,30 +1,30 @@ schema { - query: RootQuery - mutation: RootMutation + query: RootQuery + mutation: RootMutation } type Account { - avatar: MediaAttachment - createdAt: DateTime! - displayName: String - header: MediaAttachment - id: UUID! - locked: Boolean! - note: String - posts(after: String, before: String, first: Int, last: Int): PostConnection! - updatedAt: DateTime! - url: String! - username: String! + avatar: MediaAttachment + createdAt: DateTime! + displayName: String + header: MediaAttachment + id: UUID! + locked: Boolean! + note: String + posts(after: String, before: String, first: Int, last: Int): PostConnection! + updatedAt: DateTime! + url: String! + username: String! } enum CaptchaBackend { - H_CAPTCHA - M_CAPTCHA + H_CAPTCHA + M_CAPTCHA } type CaptchaInfo { - backend: CaptchaBackend! - key: String! + backend: CaptchaBackend! + key: String! } """ @@ -38,99 +38,133 @@ format, but it is always normalized to the UTC (Z) offset, e.g. scalar DateTime type Instance { - captcha: CaptchaInfo - characterLimit: Int! - description: String! - domain: String! - localPostCount: Int! - name: String! - registrationsOpen: Boolean! - userCount: Int! - version: String! + captcha: CaptchaInfo + characterLimit: Int! + description: String! + domain: String! + localPostCount: Int! + name: String! + registrationsOpen: Boolean! + userCount: Int! + version: String! } type MediaAttachment { - blurhash: String - contentType: String! - createdAt: DateTime! - description: String - id: UUID! - uploader: Account! - url: String! + blurhash: String + contentType: String! + createdAt: DateTime! + description: String + id: UUID! + uploader: Account! + url: String! } type OAuth2Application { - createdAt: DateTime! - id: UUID! - name: String! - redirectUri: String! - secret: String! - updatedAt: DateTime! + createdAt: DateTime! + id: UUID! + name: String! + redirectUri: String! + secret: String! + updatedAt: DateTime! } -"""Information about pagination in a connection""" +""" +Information about pagination in a connection +""" type PageInfo { - """When paginating forwards, the cursor to continue.""" - endCursor: String - - """When paginating forwards, are there more items?""" - hasNextPage: Boolean! - - """When paginating backwards, are there more items?""" - hasPreviousPage: Boolean! - - """When paginating backwards, the cursor to continue.""" - startCursor: String + """ + When paginating forwards, the cursor to continue. + """ + endCursor: String + + """ + When paginating forwards, are there more items? + """ + hasNextPage: Boolean! + + """ + When paginating backwards, are there more items? + """ + hasPreviousPage: Boolean! + + """ + When paginating backwards, the cursor to continue. + """ + startCursor: String } type Post { - account: Account! - attachments: [MediaAttachment!]! - content: String! - createdAt: DateTime! - id: UUID! - isSensitive: Boolean! - subject: String - updatedAt: DateTime! - url: String! - visibility: Visibility! + account: Account! + attachments: [MediaAttachment!]! + content: String! + createdAt: DateTime! + id: UUID! + isSensitive: Boolean! + subject: String + updatedAt: DateTime! + url: String! + visibility: Visibility! } type PostConnection { - """A list of edges.""" - edges: [PostEdge!]! - - """A list of nodes.""" - nodes: [Post!]! - - """Information to aid in pagination.""" - pageInfo: PageInfo! + """ + A list of edges. + """ + edges: [PostEdge!]! + + """ + A list of nodes. + """ + nodes: [Post!]! + + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! } -"""An edge in a connection.""" +""" +An edge in a connection. +""" type PostEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Post! + """ + A cursor for use in pagination + """ + cursor: String! + + """ + The item at the end of the edge + """ + node: Post! } type RootMutation { - createPost(content: String!, isSensitive: Boolean!, visibility: Visibility!): Post! - deletePost(id: UUID!): UUID! - registerOauthApplication(name: String!, redirectUri: String!): OAuth2Application! - registerUser(captchaToken: String, email: String!, password: String!, username: String!): User! - updateUser(avatar: Upload, displayName: String, header: Upload, locked: Boolean, note: String): Account! + createPost(content: String!, isSensitive: Boolean!, visibility: Visibility!): Post! + deletePost(id: UUID!): UUID! + registerOauthApplication(name: String!, redirectUri: String!): OAuth2Application! + registerUser(captchaToken: String, email: String!, password: String!, username: String!): User! + updateUser( + avatar: Upload + displayName: String + header: Upload + locked: Boolean + note: String + ): Account! } type RootQuery { - getAccountById(id: UUID!): Account - getPostById(id: UUID!): Post! - homeTimeline(after: String, before: String, first: Int, last: Int): PostConnection! - instance: Instance! - myAccount: Account! - publicTimeline(after: String, before: String, first: Int, last: Int, onlyLocal: Boolean! = true): PostConnection! + getAccountById(id: UUID!): Account + getPostById(id: UUID!): Post! + homeTimeline(after: String, before: String, first: Int, last: Int): PostConnection! + instance: Instance! + myAccount: Account! + publicTimeline( + after: String + before: String + first: Int + last: Int + onlyLocal: Boolean! = true + ): PostConnection! } """ @@ -148,17 +182,17 @@ scalar UUID scalar Upload type User { - account: Account! - createdAt: DateTime! - email: String! - id: UUID! - updatedAt: DateTime! - username: String! + account: Account! + createdAt: DateTime! + email: String! + id: UUID! + updatedAt: DateTime! + username: String! } enum Visibility { - FOLLOWER_ONLY - MENTION_ONLY - PUBLIC - UNLISTED + FOLLOWER_ONLY + MENTION_ONLY + PUBLIC + UNLISTED } diff --git a/kitsune-fe/src/client.ts b/kitsune-fe/src/client.ts index 5db164d0c..2cb2e522b 100644 --- a/kitsune-fe/src/client.ts +++ b/kitsune-fe/src/client.ts @@ -1,7 +1,7 @@ import { HoudiniClient } from '$houdini'; export default new HoudiniClient({ - url: 'http://localhost:5000/graphql' + url: `${import.meta.env.VITE_BACKEND_URL ?? ''}/graphql` // uncomment this to configure the network call (for things like authentication) // for more information, please visit here: https://www.houdinigraphql.com/guides/authentication diff --git a/kitsune-fe/src/routes/+page.svelte b/kitsune-fe/src/routes/+page.svelte index f4cd2eeb6..ad8633cb2 100644 --- a/kitsune-fe/src/routes/+page.svelte +++ b/kitsune-fe/src/routes/+page.svelte @@ -1,10 +1,63 @@
@@ -25,7 +78,13 @@
-
+ { + registerButtonDisabled = true; + handleRegister(e).finally(() => (registerButtonDisabled = false)); + }} + >

-