refactor: move studio to frontends workspace
- Move studio from root to frontends/studio/ - Add owner-tools frontend for live blog admin UI - Add shared ui component library - Set up npm workspaces for frontends - Add enhanced code block extension for editor Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c662e41b97
commit
bef5dd4437
108 changed files with 8650 additions and 441 deletions
34
frontends/studio/src/stores/apiKeys.ts
Normal file
34
frontends/studio/src/stores/apiKeys.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { atom } from 'nanostores'
|
||||
import { createFetcherStore, createMutatorStore, invalidateKeys } from './fetcher'
|
||||
import type { APIKey } from '../types'
|
||||
|
||||
export const $apiKeys = createFetcherStore<APIKey[]>(['/api/studio/api-keys'])
|
||||
|
||||
export const $creating = atom(false)
|
||||
export const $newKey = atom<string | null>(null)
|
||||
|
||||
export async function createAPIKey(name: string): Promise<APIKey> {
|
||||
$creating.set(true)
|
||||
try {
|
||||
const res = await fetch('/api/studio/api-keys', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name }),
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to create API key')
|
||||
const key = await res.json()
|
||||
$newKey.set(key.key)
|
||||
invalidateKeys('/api/studio/api-keys')
|
||||
return key
|
||||
} finally {
|
||||
$creating.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
export const $deleteAPIKey = createMutatorStore<string>(
|
||||
async ({ data: key, invalidate }) => {
|
||||
const res = await fetch(`/api/studio/api-keys/${key}`, { method: 'DELETE' })
|
||||
if (!res.ok) throw new Error('Failed to delete API key')
|
||||
invalidate('/api/studio/api-keys')
|
||||
}
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue