Files
StarPunk/starpunk/routes/__init__.py
Phil Skentelbery d8828fb6c6 feat: Implement Micropub endpoint for creating posts (Phase 3)
Following design in /docs/design/micropub-endpoint-design.md and
/docs/decisions/ADR-028-micropub-implementation.md

Micropub Module (starpunk/micropub.py):
- Property normalization for form-encoded and JSON requests
- Content/title/tags extraction from Micropub properties
- Bearer token extraction from Authorization header or form
- Create action handler integrating with notes.py CRUD
- Query endpoints (config, source, syndicate-to)
- OAuth 2.0 compliant error responses

Micropub Route (starpunk/routes/micropub.py):
- Main /micropub endpoint handling GET and POST
- Bearer token authentication and validation
- Content-type handling (form-encoded and JSON)
- Action routing (create supported, update/delete return V1 error)
- Comprehensive error handling

Integration:
- Registered micropub blueprint in routes/__init__.py
- Maps Micropub properties to StarPunk note format
- Returns 201 Created with Location header per spec
- V1 limitations clearly documented (no update/delete)

All 23 Phase 3 tests pass
Total: 77 tests pass (21 Phase 1 + 33 Phase 2 + 23 Phase 3)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 12:33:39 -07:00

52 lines
1.4 KiB
Python

"""
Route registration module for StarPunk
This module handles registration of all route blueprints including public,
admin, auth, and (conditionally) dev auth routes.
"""
from flask import Flask
from starpunk.routes import admin, auth, micropub, public
def register_routes(app: Flask) -> None:
"""
Register all route blueprints with the Flask app
Args:
app: Flask application instance
Registers:
- Public routes (homepage, note permalinks)
- Auth routes (login, callback, logout, token, authorization)
- Micropub routes (Micropub API endpoint)
- Admin routes (dashboard, note management)
- Dev auth routes (if DEV_MODE enabled)
"""
# Register public routes
app.register_blueprint(public.bp)
# Register auth routes
app.register_blueprint(auth.bp)
# Register Micropub routes
app.register_blueprint(micropub.bp)
# Register admin routes
app.register_blueprint(admin.bp)
# Conditionally register dev auth routes
if app.config.get("DEV_MODE"):
app.logger.warning(
"=" * 60
+ "\n"
+ "WARNING: Development authentication enabled!\n"
+ "This should NEVER be used in production.\n"
+ "Set DEV_MODE=false for production deployments.\n"
+ "=" * 60
)
from starpunk.routes import dev_auth
app.register_blueprint(dev_auth.bp)