Over four years since the launch of its current version, the team behind Swift server-side development framework Vapor is making room for Vapor 5, which aims at leveraging Swift 6 concurrency capabilities and laying the foundations for the framework’s future evolution. An initial alpha release is planned to be ready when Swift 6 is officially released.
Among Vapor 5 main goals are native API support for full structured concurrency, the adoption of more modern packages from the Swift ecosystem, and a full rewrite of the WebSocket and the MultipartKit APIs.
Embracing structured concurrency means Vapor 5 is going to ditch the EventLoopFuture
which was introduced in Vapor 3 and remains at the foundations of Vapor 4 more recent async/await
-based APIs. Instead, Vapor 5 will use structured concurrency from the outset and will not use EventLoopFuture
altogether, thus making it easier to reason about code and being friendlier to Xcode advanced diagnostics for structured concurrency.
Vapor 5 will also take advantage of a few third-party libraries that have become prominent in recent years, including Swift Service Lifecycle, a library to launch and stop services; Swift HTTP Types, a library that provides a common set of representations for HTTP requests and responses; and a new HTTP server based on Hummingbird, which will bring support for gRPC, async body streaming and SSE. Additionally, Vapor 5 will migrate to Swift Foundation a lightweight base layer that replaces the Foundation API delivered with iOS and macOS. This will provide consistent behaviour across all platforms and reduce confusion for multi-platform developers, says the Vapor team.
As a final note about Vapor 5, it will introduce new implementations for the WebSocket and MultipartKit APIs. The main limitation in the current MultipartKit implementation is lack of support for streaming multipart bodies, which can make it hard to work with either very large files, or with APIs like NIOFileSystem. This will be solved by the new implementation in Vapor 5. Similarly, the current Websocket APIs are hard to use in the async-await
world, and the new release will provide an updated, easier-to-use API.
Vapor comprises four main components, including a core package aimed at handling routes, JSON encoding/decoding, and managing HTTP requests; Fluent, that allows you to create data models using noSQL databases; JWT, used to create sign and verify JSON Web Tokens in Swift; and Leaf, a template engine to generate HTML from a simplified syntax.
With over 24k stars on GitHub and almost 250 contributors, Vapor seems to be the most popular choice to build HTTP web apps or APIs in Swift.
As mentioned, an early release of Vapor 5 will be available along with Swift 6, focusing on providing a fully async stack and removing all the EventLoopFuture
APIs.