refactor(server): 移除测试用的技能更新端点并清理代码格式

删除临时测试端点/api/test/update-skill/:name,该端点仅用于测试环境不再需要
同时清理了多个文件中的多余空行和代码格式
This commit is contained in:
hjjjj 2026-03-01 12:09:47 +08:00
parent a8a5f6e866
commit e86959b847

View File

@ -214,10 +214,10 @@ app.post('/api/skills/:name/publish', async (req, res) => {
if (existingSkill) {
const remoteModifiedTime = new Date(existingSkill.updated_at).getTime()
const localModifiedTime = localModifiedAt ? new Date(localModifiedAt).getTime() : 0
if (localModifiedTime < remoteModifiedTime) {
return res.status(409).json({
success: false,
return res.status(409).json({
success: false,
conflict: true,
conflictInfo: {
remote_updated_at: existingSkill.updated_at,
@ -366,13 +366,13 @@ app.delete('/api/skills/:name', async (req, res) => {
authRoutes.verifyToken(req, res, async () => {
try {
const skill = await skillsCollection.findOne({ name: req.params.name })
if (!skill) {
return res.status(404).json({ success: false, error: 'Skill not found' })
}
await skillsCollection.deleteOne({ _id: skill._id })
res.json({ success: true })
} catch (err) {
console.error('[API] Delete skill error:', err)
@ -389,56 +389,6 @@ app.get('/api/health', (req, res) => {
})
})
// Temporary endpoint to update skill version for testing
app.get('/api/test/update-skill/:name', async (req, res) => {
try {
const { name } = req.params
if (!name) {
return res.status(400).json({ success: false, error: 'Missing skill name' })
}
const skill = await skillsCollection.findOne({ name })
if (!skill) {
return res.status(404).json({ success: false, error: 'Skill not found' })
}
const now = new Date()
const versionEntry = {
version: (skill.versions?.length || 0) + 1,
description: `Updated for testing - ${now.toISOString()}`,
files: skill.files,
created_at: now,
created_by: 'System'
}
const updateData = {
$set: {
updated_at: now,
updated_by: 'System'
},
$push: { versions: versionEntry }
}
await skillsCollection.updateOne(
{ _id: skill._id },
updateData
)
res.json({
success: true,
action: 'updated',
name,
version: versionEntry.version,
updated_at: now
})
} catch (err) {
console.error('[API] Test update skill error:', err)
res.status(500).json({ success: false, error: err.message })
}
})
app.get('/api/stats', async (req, res) => {
try {
const totalSkills = await skillsCollection.countDocuments({ is_public: true })