feat: connect console to catalog and project keys
This commit is contained in:
1 parent
5e8e462548
commit
ec51e8c802
13 files changed
+503
-22
No files matched your search
@@ -204,6 +204,23 @@ async function route(request: IncomingMessage, response: ServerResponse) {
|
||||
return
|
||||
}
|
||||
|
||||
if (method === 'GET' && path === '/api/projects') {
|
||||
const user = await auth.requireUser(token)
|
||||
send(response, 200, { projects: await catalog.listProjects(user.id) })
|
||||
return
|
||||
}
|
||||
|
||||
if (method === 'POST' && path === '/api/projects') {
|
||||
const user = await auth.requireUser(token)
|
||||
const body = await readJson(request)
|
||||
const project = await catalog.createProject(user.id, {
|
||||
name: stringValue(body.name),
|
||||
...(body.description ? { description: stringValue(body.description) } : {}),
|
||||
})
|
||||
send(response, 201, { project })
|
||||
return
|
||||
}
|
||||
|
||||
if (method === 'GET' && path === '/api/keys') {
|
||||
const user = await auth.requireUser(token)
|
||||
send(response, 200, { keys: await catalog.listApiKeys(user.id) })
|
||||
@@ -215,6 +232,7 @@ async function route(request: IncomingMessage, response: ServerResponse) {
|
||||
const body = await readJson(request)
|
||||
const result = await catalog.createApiKey(user.id, {
|
||||
...(body.name ? { name: stringValue(body.name) } : {}),
|
||||
...(body.projectId ? { projectId: stringValue(body.projectId) } : {}),
|
||||
...(body.scopes !== undefined ? { scopes: stringArrayValue(body.scopes) } : {}),
|
||||
...(body.modelIds !== undefined ? { modelIds: stringArrayValue(body.modelIds) } : {}),
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user