-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
32 changed files
with
1,197 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"recommendations": [ | ||
"aaron-bond.better-comments", | ||
"antfu.iconify", | ||
"dbaeumer.vscode-eslint", | ||
"editorconfig.editorconfig", | ||
"github.copilot", | ||
"github.copilot-chat", | ||
"github.vscode-github-actions", | ||
"ms-azuretools.vscode-docker", | ||
"mtxr.sqltools", | ||
"mtxr.sqltools-driver-pg", | ||
"pflannery.vscode-versionlens", | ||
"ritwickdey.liveserver", | ||
"tamasfe.even-better-toml", | ||
"visualstudioexptteam.intellicode-api-usage-examples", | ||
"visualstudioexptteam.vscodeintellicode", | ||
"vue.volar", | ||
"vunguyentuan.vscode-css-variables", | ||
"yoavbls.pretty-ts-errors" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type OAuthProvider = 'twitch' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export interface TwitchUser { | ||
readonly id: string; | ||
readonly login: string; | ||
readonly display_name: string; | ||
readonly type: '' | 'staff' | 'admin' | 'global_mod'; | ||
readonly broadcaster_type: '' | 'affiliate' | 'partner'; | ||
readonly description: string; | ||
readonly profile_image_url: string; | ||
readonly offline_image_url: string; | ||
readonly created_at: string; | ||
// "user:read:email" scope required | ||
readonly email?: string; | ||
} | ||
|
||
export interface TwitchOAuthTokenResponse { | ||
readonly access_token: string; | ||
readonly expires_in: number; | ||
readonly refresh_token: string; | ||
readonly token_type: string; | ||
readonly scope?: string[]; | ||
} | ||
|
||
export interface TwitchUsersResponse { | ||
readonly data: TwitchUser[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<template> | ||
<div :class="$style.component"> | ||
<div :class="$style.content"> | ||
<div :class="$style.progress"> | ||
<div | ||
v-if="isFailed" | ||
:class="$style.icon" | ||
> | ||
💀 | ||
</div> | ||
|
||
<CircleSpinner | ||
v-else | ||
/> | ||
</div> | ||
|
||
<div v-if="isFailed"> | ||
Failed to connect <strong>Twitch</strong> | ||
</div> | ||
|
||
<div v-else> | ||
Connecting <strong>Twitch</strong>... | ||
</div> | ||
|
||
<PerdLink | ||
v-if="isFailed" | ||
to="/" | ||
> | ||
Return to Home | ||
</PerdLink> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { startPagePath } from '~~/constants' | ||
import CircleSpinner from '~/components/CircleSpinner.vue' | ||
import PerdLink from '~/components/PerdLink.vue'; | ||
definePageMeta({ | ||
layout: false, | ||
skipAuth: true | ||
}) | ||
const isFailed = useState(() => false) | ||
const route = useRoute() | ||
const { user } = useUserStore() | ||
async function handleConnect() { | ||
try { | ||
const result = await $fetch('/api/oauth/twitch', { | ||
method: 'POST', | ||
body: JSON.stringify({ | ||
code: route.query.code | ||
}) | ||
}) | ||
if (result === undefined) { | ||
throw new Error('Failed to connect Twitch') | ||
} | ||
user.value.userId = result.userId | ||
user.value.isAdmin = result.isAdmin | ||
user.value.hasData = true | ||
await navigateTo(startPagePath, { | ||
replace: true | ||
}) | ||
} catch (error) { | ||
isFailed.value = true | ||
} | ||
} | ||
onBeforeMount(() => { | ||
handleConnect() | ||
}) | ||
</script> | ||
|
||
<style module> | ||
.component { | ||
width: 100vw; | ||
height: 100vh; | ||
display: flex; | ||
overflow: hidden; | ||
padding: var(--spacing-24); | ||
} | ||
.content { | ||
display: grid; | ||
row-gap: var(--spacing-16); | ||
margin: auto; | ||
justify-items: center; | ||
text-align: center; | ||
text-wrap: balance; | ||
} | ||
.progress { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 48px; | ||
height: 48px; | ||
} | ||
.icon { | ||
font-size: 32px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { RouteLocationNormalized } from 'vue-router' | ||
|
||
export function shouldSkipAuth(to: RouteLocationNormalized) { | ||
return to.meta.skipAuth === true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.