From 3a669440809c254e1a0c3f576e8999e4126a1648 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 11 Jan 2023 22:50:52 +0000 Subject: [PATCH] chore: remove `/invite` route preparatory to launch --- modules/tauri/runtime/nitro.client.ts | 4 -- nuxt.config.ts | 14 ------ server/routes/invite.get.ts | 66 --------------------------- 3 files changed, 84 deletions(-) delete mode 100644 server/routes/invite.get.ts diff --git a/modules/tauri/runtime/nitro.client.ts b/modules/tauri/runtime/nitro.client.ts index 0694fc56..3c31db13 100644 --- a/modules/tauri/runtime/nitro.client.ts +++ b/modules/tauri/runtime/nitro.client.ts @@ -5,7 +5,6 @@ import { toNodeListener, } from 'h3' import { createFetch } from 'ofetch' -import { parseURL } from 'ufo' import { createCall, createFetch as createLocalFetch, @@ -26,13 +25,10 @@ const handlers = [ }, ] -const { protocol, host } = parseURL(window.location.href) - // @ts-expect-error undeclared global window property window.__NUXT__.config = { // @ts-expect-error undeclared global window property ...window.__NUXT__.config, - deployUrl: `${protocol}//${host}`, storage: {}, } diff --git a/nuxt.config.ts b/nuxt.config.ts index 3b1cd2e7..e250c72e 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -71,25 +71,11 @@ export default defineNuxtConfig({ }, }, runtimeConfig: { - deployUrl: !isCI - ? 'http://localhost:5314' - : isPreview - ? process.env.DEPLOY_PRIME_URL - : 'https://elk.zone', cloudflare: { accountId: '', namespaceId: '', apiToken: '', }, - discord: { - inviteUrl: 'https://chat.elk.zone', - }, - github: { - // oauth flow - clientId: '', - clientSecret: '', - inviteToken: '', - }, public: { env: '', // set in build-env module buildInfo: {} as BuildInfo, // set in build-env module diff --git a/server/routes/invite.get.ts b/server/routes/invite.get.ts deleted file mode 100644 index 50aa93a3..00000000 --- a/server/routes/invite.get.ts +++ /dev/null @@ -1,66 +0,0 @@ -const query = (accessToken: string, query: string) => - $fetch<{ data: any }>('https://api.github.com/graphql', { - method: 'POST', - headers: { Authorization: `Bearer ${accessToken}` }, - body: { query }, - }) - -export default defineEventHandler(async (event) => { - const { code } = getQuery(event) - - const config = useRuntimeConfig() - - if (!code) { - const redirect = `&redirect_uri=${config.deployUrl}/invite` - const loginURL = `https://github.com/login/oauth/authorize?client_id=${config.github.clientId}${redirect}` - await sendRedirect(event, loginURL) - return - } - - const { access_token } = await $fetch<{ access_token: string }>( - 'https://github.com/login/oauth/access_token', - { - method: 'POST', - body: { - client_id: config.github.clientId, - client_secret: config.github.clientSecret, - code, - }, - }, - ) - - if (!access_token) { - throw createError({ - statusCode: 422, - statusMessage: 'Authorisation code invalid.', - }) - } - - const id = await query(access_token, '{ viewer { databaseId } }') - .then(r => r.data?.viewer.databaseId) - - if (!id) { - throw createError({ - statusCode: 422, - statusMessage: 'Access code invalid.', - }) - } - - await $fetch( - 'https://api.github.com/orgs/elk-zone/invitations', - { - method: 'POST', - body: { invitee_id: id, role: 'direct_member', team_ids: [7042932] }, - headers: { - 'Accept': 'application/vnd.github+json', - 'Authorization': `Bearer ${config.github.inviteToken}`, - 'X-GitHub-Api-Version': '2022-11-28', - }, - }, - ) - - return sendRedirect( - event, - config.discord.inviteUrl, - ) -})