Tim's Profile

Profile picture for Tim



Twitter @0xtim
Founder of Broken Hands
Better known as 0xTim on the Vapor slack channel, I'm a software engineer with a varied background across everything from embedded development, reverse-engineering and mobile apps.

Tim's Posts

13 posts

Introducing Leaf Error Middleware

Sunday, October 1, 2017 by Tim

Leaf Error Middleware

One of the more interesting things to add to your website is a custom error page and 404 page. A clever and unique 404 page not only serves to help your users find their way back to your site, but can also distinguish your site from the standard '404 Not Found' page. Really good 404 pages can even lead to more traffic to your site!

The SteamPress Example site has had this functionality for some time now but I saw more and more questions about how people could change the 404 page or the error view on their site so I decided to do it properly!

A few commits, many proper tests and several builds later and Leaf Error Middleware was born! You can add it to your site simply by adding the dependency and then adding it to your middleware. Then you provide the 404 and error pages and it all just works!

Fluent Part 2 - Parent-Child Relationships

Thursday, September 28, 2017 by Tim

This is the third tutorial of a series of tutorials on Vapor. For more, click here


In the last tutorial we started to put together some parts of our Reminders application and we can now create and view reminders. In this tutorial we are going to add some more complexity to our application by introducing relationships between different models. By the end of this tutorial you will set up a parent-child relationship between a new User model and our existing Reminder model.

If you have been following along with the tutorial from the start, or are using an old template, you will need to upgrade your project for Swift 4. I have already written a short post on the basic steps, but you can also see this commit for the changes required to your Package.swift. Thankfully, at this stage, as we don't have much code, that is all that needs to be done!

Migrating Your Server Side App to Swift 4

Thursday, September 21, 2017 by Tim

I have noticed a lot of people on the Vapor slack asking about how to migrate to Swift 4 so I thought I would write a short post about it. Whilst some of this may be relevant to iOS, for the most part it is concentrating on Swift Package Manager so mainly applies to Server-Side Swift. I also won't talk much about the language changes - there are far better posts that already do!

Swift 4

Swift 4 is out! With the release of Xcode 9 this week, most people are now probably running Swift 4. The highlight is that the list of things you need to do for the most part to get your app working in Swift 4 is....NOTHING!

Remember the major upheaval when Swift 3 came out? There were breaking changes galore and you had to do two or three runs of the migrator in Xcode and even then you were still left with hundreds of errors. Now that Swift is another year older and another year maturer, the migration is a lot smoother.

Fluent And Controllers - Part 1

Monday, September 11, 2017 by Tim

This is the second tutorial of a series of tutorials on Vapor. For more, click here


In the last tutorial we learnt how to get started with Vapor and create a new project from a template. However, now we want to actually be able to do something with it! As I mentioned before, this series of tutorials will be based on creating a Reminders app, so today we are going to learn how to save and retrieve reminders from a database.

Before we get started, we need to remove all of the stuff from the template that we aren't going to use. So delete the tests directory (don't worry we'll come back to tests in a future tutorial!) and the files from the Controllers and Models directories in the Sources/App directory:

Testing Vapor - A Deep Dive

Sunday, September 3, 2017 by Tim

This is a write up of the talk I gave at July’s Vapor London Meetup. The slides from that presentation can be found here. WARNING: this post has turned into a bit of an epic one, coming in at 8,000 words! Although I’ll skim over some basics of testing Vapor, it is a deep dive and for those who don’t feel comfortable with testing at all, I recommend reading some of the other excellent tutorials out there first.

Vapor XCTest

Software testing has been around as long as software has been, but the practices certainly aren’t the same as back when software was written on punch cards! In these days of deploying to live multiple times, or even hundreds of times a day, the way we approach testing software has had to keep up with the demands of continuous delivery and continuous deployment.