mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
- Reorganize v3/ into implementation/ subfolders: - planning/, architecture/, migration/, integration/ - security/, adrs/, research/, swarm-plans/ - Add 15-agent concurrent swarm implementation plans: - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x) - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies - Update .claude/settings.json with proper hooks format - Add bash aliases for claude --dangerously-skip-permissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
101 lines
2.4 KiB
JavaScript
101 lines
2.4 KiB
JavaScript
const express = require('express');
|
|
const app = express();
|
|
const port = process.env.PORT || 3000;
|
|
|
|
// Middleware
|
|
app.use(express.json());
|
|
|
|
// In-memory data store
|
|
let items = [
|
|
{ id: 1, name: 'Item 1', description: 'This is the first item' },
|
|
{ id: 2, name: 'Item 2', description: 'This is the second item' }
|
|
];
|
|
let nextId = 3;
|
|
|
|
// Routes
|
|
// GET all items
|
|
app.get('/api/items', (req, res) => {
|
|
res.json(items);
|
|
});
|
|
|
|
// GET single item
|
|
app.get('/api/items/:id', (req, res) => {
|
|
const item = items.find(i => i.id === parseInt(req.params.id));
|
|
if (!item) {
|
|
return res.status(404).json({ error: 'Item not found' });
|
|
}
|
|
res.json(item);
|
|
});
|
|
|
|
// POST new item
|
|
app.post('/api/items', (req, res) => {
|
|
const { name, description } = req.body;
|
|
if (!name || !description) {
|
|
return res.status(400).json({ error: 'Name and description are required' });
|
|
}
|
|
|
|
const newItem = {
|
|
id: nextId++,
|
|
name,
|
|
description
|
|
};
|
|
items.push(newItem);
|
|
res.status(201).json(newItem);
|
|
});
|
|
|
|
// PUT update item
|
|
app.put('/api/items/:id', (req, res) => {
|
|
const id = parseInt(req.params.id);
|
|
const { name, description } = req.body;
|
|
|
|
const itemIndex = items.findIndex(i => i.id === id);
|
|
if (itemIndex === -1) {
|
|
return res.status(404).json({ error: 'Item not found' });
|
|
}
|
|
|
|
items[itemIndex] = {
|
|
id,
|
|
name: name || items[itemIndex].name,
|
|
description: description || items[itemIndex].description
|
|
};
|
|
|
|
res.json(items[itemIndex]);
|
|
});
|
|
|
|
// DELETE item
|
|
app.delete('/api/items/:id', (req, res) => {
|
|
const id = parseInt(req.params.id);
|
|
const itemIndex = items.findIndex(i => i.id === id);
|
|
|
|
if (itemIndex === -1) {
|
|
return res.status(404).json({ error: 'Item not found' });
|
|
}
|
|
|
|
items.splice(itemIndex, 1);
|
|
res.status(204).send();
|
|
});
|
|
|
|
// Health check
|
|
app.get('/health', (req, res) => {
|
|
res.json({ status: 'OK', timestamp: new Date().toISOString() });
|
|
});
|
|
|
|
// Root endpoint
|
|
app.get('/', (req, res) => {
|
|
res.json({
|
|
message: 'Welcome to Simple REST API',
|
|
endpoints: {
|
|
'GET /api/items': 'Get all items',
|
|
'GET /api/items/:id': 'Get a single item',
|
|
'POST /api/items': 'Create a new item',
|
|
'PUT /api/items/:id': 'Update an item',
|
|
'DELETE /api/items/:id': 'Delete an item',
|
|
'GET /health': 'Health check'
|
|
}
|
|
});
|
|
});
|
|
|
|
// Start server
|
|
app.listen(port, () => {
|
|
console.log(`Simple REST API server running on http://localhost:${port}`);
|
|
}); |