feat: basic oauth

This commit is contained in:
Anthony Fu 2022-11-15 23:48:23 +08:00
parent 72b13f5265
commit 7ab17001f0
16 changed files with 199 additions and 106 deletions

View file

@ -1,19 +1,17 @@
import { $fetch } from 'ohmyfetch'
export interface AppInfo {
id: string
name: string
website: string | null
redirect_uri: string
client_id: string
client_secret: string
vapid_key: string
}
import type { AppInfo } from '~/types'
export const registeredApps: Record<string, AppInfo> = {}
const promise = $fetch(process.env.APPS_JSON_URL || 'http://localhost:3000/registered-apps.json')
.then(r => Object.assign(registeredApps, r))
.catch((e) => {
if (process.dev)
console.error('Failed to fetch registered apps,\nyou may need to run `nr register-apps` first')
else
console.error('Failed to fetch registered apps')
console.error(e)
})
export async function getApp(server: string) {
await promise