-
-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Labels
breaking changeBreaking changeBreaking changecomponent/federationFederation object relatedFederation object relatedcomponent/integrationWeb framework integrationWeb framework integrationdifficulty/intermediateIntermediate levelIntermediate levelexamplesExample code relatedExample code related
Milestone
Description
Background
Fresh 2.0 has introduced significant changes to its middleware API and overall architecture. The current Fedify integration module @fedify/fedify/x/fresh was designed for Fresh 1.x and is incompatible with these changes. We need to create a new package that properly integrates with Fresh 2.0's updated middleware system.
Key changes in Fresh 2.0
- Unified middleware signatures: Middleware now receives a single context object instead of
(req, ctx)parameters - Request object location: The
Requestobject is now accessed viactx.reqinstead of being a separate parameter - Context consolidation: Various context interfaces (
AppContext,LayoutContext,RouteContext) have been unified into a singleContextinterface - Simplified configuration: No more
fresh.config.tsorfresh.gen.tsfiles - Vite integration: Fresh 2.0 uses Vite for development and build processes
Requirements
Package structure
- Package name:
@fedify/fresh - Target: Fresh 2.0+ compatibility
- Release timeline: Aligned with Fedify 2.0 release
Middleware implementation
The new middleware should:
- Follow Fresh 2.0's unified middleware signature pattern:
(ctx: Context) => Response | Promise<Response> - Access the request via
ctx.reqinstead of as a separate parameter - Properly integrate with Fresh's new context system
- Support all existing Fedify federation features
API compatibility
- Maintain feature parity with the current
@fedify/fedify/x/freshmodule - Adapt to Fresh 2.0's context-based approach
- Ensure smooth migration path for existing users
Technical specifications
Middleware signature
// Fresh 1.x pattern (old)
export function federation(req: Request, ctx: FreshContext): Response | Promise<Response>
// Fresh 2.0 pattern (new)
export function federation(ctx: Context): Response | Promise<Response>Context access patterns
- Use
ctx.reqfor request access - Use
ctx.urlfor URL information - Use
ctx.statefor passing data between middlewares - Use
ctx.paramsfor route parameters
Tasks
- Create new package structure for
@fedify/fresh - Implement Fresh 2.0 compatible middleware
- Update type definitions for Fresh 2.0 context
- Migrate existing functionality from
@fedify/fedify/x/fresh - Add comprehensive tests for Fresh 2.0 integration
- Write migration guide from
@fedify/fedify/x/freshto@fedify/fresh - Update documentation with Fresh 2.0 examples
- Ensure compatibility with Vite build process
References
- Fresh 2.0 Migration Guide
- Fresh 2.0 Context API
- Current implementation:
@fedify/fedify/x/fresh
Acceptance criteria
- The package works seamlessly with Fresh 2.0
- All existing Fedify federation features are supported
- Type safety is maintained with proper TypeScript definitions
- Documentation includes clear examples for Fresh 2.0
- Migration path from the old module is documented
- Tests pass for all federation scenarios in Fresh 2.0 environment
Metadata
Metadata
Assignees
Labels
breaking changeBreaking changeBreaking changecomponent/federationFederation object relatedFederation object relatedcomponent/integrationWeb framework integrationWeb framework integrationdifficulty/intermediateIntermediate levelIntermediate levelexamplesExample code relatedExample code related