Week 15

News

Weekversary of Vapor 3 🎉🎉🎉. This week has been particularly interesting because of the amount of articles and tutorials the Vapor Community have contributed, Vapor now has its own thread at the Swift Forums, and most importantly, Vapor 3.1, yes, you read it right, Vapor’s development team is restless already thinking on 3.1, awesome, is not it?

New Features

Add a non-variadic ‘on’ method to router

Adds a non-variadic overload to router.on(...) to allow users to crete routes with arrays of parameters.

The following snippet creates a Route at the provided path using an HTTP method. This route will return "Hello, world" to GET requests to /hello/world

router.on(.GET, at: ["hello", "world"]) { req in
	return "Hello, world!"
}

You can use anything that conforms to PathComponentsRepresentable to create the path, including type constrained parameters.

router.on(.GET, at: ["users", Int.parameter]) { req in
	let id = try req.parameters.next(Int.self)
	return "User #\(id)"
}

vapor/vapor#1666

Model cleanup (more than that)

vapor/auth#39

Export Crypto in Authentication

Export Crypto in Authentication so using things like the BCryptDigest for setting up a password verifier don’t require an import Crypto

vapor/auth#3

NIO

Implement lazy selector registration

Motivation:

Previously we would eagerly register any fd with the selector (epoll/kqueue) which works well with kqueue. With epoll however, you’ll get EPOLLHUP immediately if you supplied a socket that hasn’t had connect/bind called on it. We got away with this because we took quite a bit of care to always make sure we call connect/bind pretty much immediately after we registered it. And crucially before we ever asked the selector to tell us about new events.

Modifications:

Made selector registration lazy (when we try activating the channel by calling connect/bind)

Result:

The user can now register and connect whenever they feel like it, fixes apple/swift-nio#380

apple/swift-nio#388

Add support for compiling and running NIO on Raspberry Pi 32-bit

Motivation:

Pretty much every developer in the world want to run MicroExpress applications on Raspberry Pi K8s clusters. The unfortunate precondition to that is getting NIO compiled for RaspberryPi. This PR makes it work.

Thanks go to @chnmrc for providing a Swift 4.1 Raspi build, also available via a DockerHub: helje5/rpi-swift.

Modifications:

Two main changes:

Result:

NIO compiles on Raspi 3, 32-bit Ubuntu. I tried the Echo Server, which seems to work, and also the HTTP sample Server, which also seems to work.

P.S.: This should also allow you to run NIO on AppleWatch, which is 32-bit too.

apple/swift-nio#383

Community Contributions

Add support for SSL-enabled Postgres servers

vapor/postgresql#57

vapor/postgresql#50

Rename makeResponse to response

Renames req.makeResponse() to req.response()

vapor/vapor#1672

vapor/vapor#1671

Add Data responses and TypedDataResponse

In some cases, you may want to just return raw Data

vapor/vapor#1657

Feature/infer auth type from context

This PR allows

secured.get("me") { request -> U in
    try request.requireAuthenticated()
}

instead of

secured.get("me") { request -> U in
    try request.requireAuthenticated(U.self)
}

Same for the other authentication methods.

vapor/auth#37

Remove unnecessary Model conformance on Authenticatable

Authenticatable types no longer need to be Models

vapor/auth#35

Tagged releases

Articles

Vapor 3.0.0 release article

Brought to you by Vapor’s development team

Vapor 3 Release

Server Side Swift frameworks comparison

A bit old, given the fact everything changes really fast (Feb)

Server Side Swift Frameworks Comparison

Transforming from Vapor 2 to Vapor 3

Brought to you by @calebkleveter

From Vapor 2 to Vapor 3

CRUD using Leaf

Brought to you by @MartinLasek

CRUD using Leaf

Routing and Fluent

Brought to you by @calebkleveter

Routing and Fluent

Deploying Vapor 3 on Cloud Foundry

Brought to you by @idev4u

Deploying Vapor 3 in Cloud Foundry

HTTP Basic Auth with Vapor 3

Brought to you by @anapaix

HTTP Basic Auth with Vapor 3

Getting started with Vapor 3 (Updated)

Brought to you by Paul Hudson

Getting started with Vapor 3

Want to know more or get inspired?

Take action

There are many ways you can contribute with Vapor

Writing Credits

@frivas

@twof