Hands-On Server-Side Web Development with Swift
eBook - ePub

Hands-On Server-Side Web Development with Swift

Build dynamic web apps by leveraging two popular Swift web frameworks: Vapor 3.0 and Kitura 2.5

  1. 404 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Server-Side Web Development with Swift

Build dynamic web apps by leveraging two popular Swift web frameworks: Vapor 3.0 and Kitura 2.5

About this book

Take advantage of using the same programming language for both server and client-side with this hands-on book for building web applications with Swift.

Key Features

  • Build a full-stack iOS and web applications using Swift, Vapor, and Kitura Framework
  • Leverage ORM abstraction drivers to make queries to SQL database
  • Develop your very own containerized microservices with Swift, Docker and Kubernetes

Book Description

This book is about building professional web applications and web services using Swift 4.0 and leveraging two popular Swift web frameworks: Vapor 3.0 and Kitura 2.5. In the first part of this book, we'll focus on the creation of basic web applications from Vapor and Kitura boilerplate projects. As the web apps start out simple, more useful techniques, such as unit test development, debugging, logging, and the build and release process, will be introduced to readers.

In the second part, we'll learn different aspects of web application development with server-side Swift, including setting up routes and controllers to process custom client requests, working with template engines such as Leaf and Stencil to create dynamic web content, beautifying the content with Bootstrap, managing user access with authentication framework, and leveraging the Object Relational Mapping (ORM) abstraction layer (Vapor's Fluent and Kitura's Kuery) to perform database operations.

Finally, in the third part, we'll develop web services in Swift and build our API Gateway, microservices and database backend in a three-tier architecture design. Readers will learn how to design RESTful APIs, work with asynchronous processes, and leverage container technology such as Docker in deploying microservices to cloud hosting services such as Vapor Cloud and IBM Cloud.

What you will learn

  • Build simple web apps using Vapor 3.0 and Kitura 2.5
  • Test, debug, build, and release server-side Swift applications
  • Design routes and controllers for custom client requests
  • Work with server-side template engines
  • Deploy web apps to a host in the cloud
  • Enhance web content with Bootstrap
  • Manage user access using authentication framework
  • Design for API gateway
  • Develop an iPhone app to work with web services
  • Deploy your app as a microservice in a cluster
  • Deploy Swift web services with a RESTful API design

Who this book is for

This book is about building professional web applications and web services using Swift and leveraging two popular Swift web frameworks: Vapor 3.0 and Kitura 2.5. We assume the readers to have some working knowledge of Swift programming language. The readers could be beginners of Swift programming, seasonal iOS or macOS developers, or software developers who want to work on practical Swift applications while learning the language itself. By the end of the book, you would be able to successfully create your own web applications and web services by leveraging the powerful ecosystem of Swift.

Trusted by 375,005 students

Access to over 1.5 million titles for a fair monthly price.

Study more efficiently using our study tools.

Information

Year
2018
Print ISBN
9781789341171
eBook ISBN
9781789345865

Vapor Boilerplate Project

This topic in the appendix will give you a clear understanding the boilerplate code in Vapor. Carrying forward from where we left off in Chapter 3, Building Your First Web App, here is a summary of the steps that you've used in creating a helloWorld boilerplate project using Vapor's default template:
$ vapor new helloWorld $ cd helloWorld $ vapor build $ vapor xcode $ open hellowWorld.xcodeproj
After executing the preceding commands in the Terminal, you changed Xcode project's scheme to Run and device to My Mac. The helloWorld server will be running at http://localhost:8080 when you use command + R to run your project.
The following sections will provide you with a better idea regarding the same:
  • Reviewing Vapor-generated files
  • Understanding the source code files
  • Configuring Swift Package Manager
  • Starting with entry point
  • Instantiating an application object
  • Configuring before instantiating application
  • Adding initialization code after application instantiation
  • Registering the application's routes
  • Implementing endpoint logic in controllers
  • Using a data model

Reviewing Vapor-generated files

After using the preceding steps to create a boilerplate helloWorld project, use the ls -a command in the helloWorld project directory to list all files and child directories:
# List all files and directories, including the hidden ones ls -a
The -a flag is used here so you can view all files, including hidden files and directories:
. .build .gitignore Package.swift README.md Tests cloud.yml
.. .git Package.resolved Public Sources circle.yml
Vapor generates some hidden directories, such as .build and .git.
The .build directory contains all the dependencies and temporary files when you build your project. If you execute the vapor clean Vapor CLI command, the .build directory will be removed. Then you have to use vapor...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. About Packt
  4. Contributors
  5. Preface
  6. Introducing Server-Side Swift
  7. Getting Started with Vapor and Kitura
  8. Building Your First Web App
  9. Debugging and Testing
  10. Setting Up Routes and Controllers
  11. Working with Template Engines
  12. Bootstrapping Your Design
  13. Employing Storage Framework
  14. Adding Authentication
  15. Understanding Technologies for Web Services
  16. Designing for API Gateway
  17. Deploying to the Cloud
  18. Developing an iPhone Client
  19. Developing Microservices
  20. Vapor Boilerplate Project
  21. Kitura Boilerplate Project
  22. Other Books You May Enjoy

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.5M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1.5 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Hands-On Server-Side Web Development with Swift by Angus Yeung in PDF and/or ePUB format, as well as other popular books in Informatique & Langues de programmation. We have over 1.5 million books available in our catalogue for you to explore.