Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 10, 2025

🚀 Implementation Summary

This PR implements issue #32 to create a REST API that uses LINO (Links Notation) instead of JSON, bringing web service capabilities to the CLI tool while preserving all existing functionality.

🔧 Key Features

REST API Server

  • New serve command to start REST API server on configurable host/port
  • LinksController with full CRUD operations via REST endpoints
  • LINO query support in request bodies instead of traditional JSON payloads
  • Swagger integration for API documentation and testing

API Endpoints

Method Endpoint Description
GET /api/links Get all links from database
POST /api/links Create new links using LINO syntax
PUT /api/links Update existing links using LINO syntax
DELETE /api/links Delete links using LINO syntax
POST /api/links/query Execute arbitrary LINO queries

Usage Examples

# Start the server
clink serve --port 5000 --host localhost

# Create links via REST API
curl -X POST http://localhost:5000/api/links \
  -H "Content-Type: application/json" \
  -d '{"query": "() ((1 1) (2 2))"}'

# Update links
curl -X PUT http://localhost:5000/api/links \
  -H "Content-Type: application/json" \
  -d '{"query": "((1: 1 1)) ((1: 1 2))"}'

📁 Files Added/Modified

New Files

  • Foundation.Data.Doublets.Cli/LinksController.cs - REST API controller implementing LINO endpoints
  • examples/lino-examples.md - Comprehensive API usage examples and documentation
  • examples/test-rest-api.sh - Test script for API functionality verification

Modified Files

  • Foundation.Data.Doublets.Cli/Program.cs - Added server command and ASP.NET Core integration
  • Foundation.Data.Doublets.Cli/Foundation.Data.Doublets.Cli.csproj - Added web framework dependencies, version bump to 2.3.0
  • README.md - Added REST API documentation section with examples

✅ Quality Assurance

  • All existing tests pass (124/124 passing)
  • CLI functionality preserved - all original commands work exactly as before
  • Version bump to 2.3.0 reflecting the significant new feature
  • Comprehensive documentation with usage examples
  • Test scripts provided for easy verification

🎯 Design Decisions

  1. LINO over JSON: The API uses LINO queries in request bodies instead of traditional JSON data structures, fulfilling the core requirement
  2. Dual mode operation: The tool supports both CLI and server modes without breaking changes
  3. Standard REST patterns: Uses conventional HTTP methods (GET, POST, PUT, DELETE) for intuitive API usage
  4. Swagger integration: Provides interactive documentation at /swagger endpoint
  5. Configurable server: Supports custom host, port, database path, and trace options

🚦 Testing

Start the server and visit http://localhost:5000/swagger for interactive API documentation, or run the provided test script:

cd examples
./test-rest-api.sh

Fixes #32

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #32
@konard konard self-assigned this Sep 10, 2025
konard and others added 2 commits September 10, 2025 15:23
Implements issue #32 to create a REST API that uses LINO (Links Notation) instead of JSON. The server provides REST endpoints for all CRUD operations while maintaining the existing CLI functionality.

Key features:
- New 'serve' command to start REST API server on configurable host/port
- LinksController with endpoints: GET, POST, PUT, DELETE /api/links and POST /api/links/query
- LINO query support in request bodies instead of traditional JSON payloads
- Swagger documentation integration for API exploration
- Comprehensive examples and documentation
- Version bump to 2.3.0 for new major feature

All existing CLI functionality preserved and all tests passing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] LINO API (REST) Add LINO REST API server functionality Sep 10, 2025
@konard konard marked this pull request as ready for review September 10, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LINO API (REST)

2 participants