Getting Started with Vapor
In the previous chapter, we went over how to make an iOS app using Xcode in pure Swift. We also covered different concepts in iOS development such as Model View Controller (MVC) pattern and how to build iOS apps using the models which contain the state of our app. We also went over how to use the controller to control the flow of our app, to add, delete, and rearrange items and shopping lists. We also covered how to configure the views in storyboard to define the look and feel of the app, such as the navigation bar to table view cells. We also used some of the elegant syntax provided by Swift to help us aggregate all of the changes to our models and use a consistent method to save the state of the application, so that it can be easily restored using extensions built in the Array class, codable protocol, UserDefaults, and Swift's didSet callback methods.
In this chapter, we will put our server-side engineering hat on and explore Swift on the server side, using Vapor framework. We will see how we can use Vapor to build an API server for the iOS app we just built. We will also explore the modularity of the framework, as Vapor is made up of multiple Swift packages built using the Swift package manager that we went over in Chapter 1, Getting Started with Server Swift, it is a framework built purely in Swift, with performance in mind. More specifically, in this chapter, we will cover the following topics:
- What is Vapor, and what Swift packages make up Vapor? What functionality do these Swift packages provide?
- How can these Swift packages be used to build a simple HTTP server or your own web framework?
- What is the Vapor toolbox, and how do you use it to start building Vapor apps?
- How can you create and run a simple Vapor application server?
- How is our Vapor app structured?