feat: opt web ux
This commit is contained in:
@@ -2,7 +2,6 @@ import { Router, type Router as RouterType } from 'express';
|
||||
import { z } from 'zod';
|
||||
import { prisma } from '@agent-fox/shared';
|
||||
import { requireAuth } from '../middleware/auth.js';
|
||||
import { generateApiKey } from '../lib/api-key.js';
|
||||
import { parseOpenApiDocument } from '../services/openapi-parser.js';
|
||||
|
||||
const router: RouterType = Router();
|
||||
@@ -18,7 +17,6 @@ router.post('/', async (req, res) => {
|
||||
try {
|
||||
const input = specUrl || spec;
|
||||
const parsed = await parseOpenApiDocument(input);
|
||||
const { raw: apiKey, hash: apiKeyHash } = generateApiKey();
|
||||
|
||||
const project = await prisma.$transaction(async (tx) => {
|
||||
const proj = await tx.project.create({
|
||||
@@ -29,7 +27,6 @@ router.post('/', async (req, res) => {
|
||||
baseUrl: parsed.baseUrl,
|
||||
openApiSpec: parsed.spec as any,
|
||||
openApiVersion: parsed.openApiVersion,
|
||||
apiKeyHash,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -64,7 +61,6 @@ router.post('/', async (req, res) => {
|
||||
success: true,
|
||||
data: {
|
||||
project: { id: project.id, name: project.name },
|
||||
apiKey,
|
||||
stats: { modules: parsed.modules.length, endpoints: parsed.endpoints.length },
|
||||
},
|
||||
});
|
||||
@@ -136,17 +132,4 @@ router.delete('/:id', async (req, res) => {
|
||||
res.json({ success: true, data: { deleted: true } });
|
||||
});
|
||||
|
||||
router.post('/:id/api-key/rotate', async (req, res) => {
|
||||
const { raw, hash } = generateApiKey();
|
||||
const result = await prisma.project.updateMany({
|
||||
where: { id: req.params.id, userId: req.user!.userId },
|
||||
data: { apiKeyHash: hash },
|
||||
});
|
||||
if (result.count === 0) {
|
||||
res.status(404).json({ success: false, error: { code: 'NOT_FOUND', message: 'Project not found' } });
|
||||
return;
|
||||
}
|
||||
res.json({ success: true, data: { apiKey: raw } });
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user