Hands-On Server-Side Web Development with Swift
Angus Yeung更新时间:2021-06-10 19:01:21
最新章节:Leave a review - let other readers know what you thinkcoverpage
Title Page
About Packt
Why subscribe?
Packt.com
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
Introducing Server-Side Swift
Introducing Swift
Open sourcing Swift and components
Swift compiler
Swift standard library
Swift foundation framework
Dispatch framework
XCTest testing framework
Swift Package Manager
LLDB debugger
CommonMark documentation
Bringing Swift to the server-side
SwiftNIO
Surveying Swift server-side frameworks
Vapor
Kitura
Perfect
Choosing the right framework
Performance
Feature sets
Ecosystem
Community support
Vapor
Kitura
Perfect
Summary
Getting Started with Vapor and Kitura
Installing Vapor and Kitura on Mac
Preparing your Mac for server-side Swift development
Installing the Xcode IDE on your Mac
Installing Xcode Command Line Tools
Installing Homebrew
Installing Vapor Toolbox on Mac
Checking your system's compatibility with Vapor
Installing Vapor Toolbox using Homebrew
Verifying Vapor installation
Installing the Kitura CLI on Mac
Installing Vapor and Kitura on Ubuntu
Working with the Ubuntu APT
Installing the Swift Toolchain on Linux
Installing Vapor on Ubuntu
Option 1 – using script to clone Vapor packages
Option 2 – cloning Vapor packages manually
Installing Vapor on Ubuntu
Installing Kitura on Ubuntu
Installing required Linux system packages
Exploring Vapor Toolbox and the Kitura CLI
Using Vapor Toolbox Commands
Getting help on a specific Vapor command
Exploring the Kitura CLI
Using KAG
Selecting a scaffolded application
Choosing additional services
Summary
Building Your First Web App
Creating an app using Vapor CLI
Creating a hello world app from a template
Building the hello world app
Running the hello world app
Converting to the Xcode project on a Mac
Reviewing source code in Vapor boilerplate
Adding more routes in Vapor
Creating an app using Kitura CLI
Creating a hello world app from a default template
Running your Kitura app from a Terminal
Running your Kitura app from Xcode
Testing the app with a web browser client
Reviewing source code in Kitura boilerplate
Adding more routes in Kitura
Summary
Debugging and Testing
Writing tests for server-side Swift projects
Preparing a test executable target
Writing tests using XCTest
Checking out test cases in a Vapor boilerplate project
Learning useful assertion macros
Adding a unit test to your project
Running unit tests in Xcode
Checking code coverage
Turning on code coverage
Generating a coverage report
Reviewing Kitura boilerplate tests
Handling asynchronous tests
Using extensions for functions common to all tests
Debugging in a server-side Swift project
Using the Logging API in a Vapor project
Using the Logger API in a Kitura Project
Debugging using the HTTP traffic monitoring tool
Debugging using Postman
Debugging using the curl command in the Terminal
Summary
Setting Up Routes and Controllers
Adding custom routes in a Vapor project
Modeling your data with content type
Using controller for logical operations
Using Vapor's route collection
Grouping related routes
Implementing route handlers
Retrieving all entries
Creating a new entry with a unique ID
Retrieving an entry
Updating an entry
Deleting an entry
Testing the routes
Adding custom routes in a Kitura project
Modeling Codable data
Using controllers for logical operations
Implementing Codable routing
Handling Kitura routes
Summary
Working with Template Engines
Using the Leaf templating engine in Vapor
Configuring the Leaf templating engine
Using the basic functions of the Leaf templating engine
Using variables and tags in Leaf templating
Setting a variable
Working with context
Looping through a collection
Checking conditions
Embedding other templates
Adding more Leaf templates
Displaying all journal entries
Completing the features
Templating with Stencil in a Kitura project
Learning the basic functions of the Stencil templating engine
Using variables and tags in Stencil templating
Summarizing useful filters and tags in Stencil
Configuring the Stencil templating engine
Developing code working with Stencil templates
Adding Stencil templates to your Kitura project
Displaying all journal entries
Completing the features
Creating a new journal entry
Editing a journal entry
Removing a journal entry
Summary
Bootstrapping Your Design
Getting started with the Bootstrap framework
Setting up for Bootstrap
Inserting the stylesheet
Adding dependency for JavaScript files
Using a starter template in Bootstrap
Using basic Bootstrap components
Organizing content into grids
Displaying a jumbotron with parallax animation
Adding a navigation bar
Using form controls
Reusing glyphicons
Using Bootstrap for a Vapor application
Enhancing Leaf templates with Bootstrap
header.leaf
footer.leaf
main.leaf
new.leaf
entry.leaf
Using Bootstrap for Kitura
Enhancing Stencil templates with Bootstrap
header.stencil
footer.stencil
main.stencil
new.stencil
entry.stencil
Summary
Employing Storage Framework
Installing databases
Installing PostgreSQL
Installing SQLite
Installing MySQL
Working with the Fluent Framework in Vapor
Choosing a database driver
Using the PostgreSQL database driver
Using the SQLite database driver
Using the MySQL database driver
Conforming to the Fluent Model
Creating a new Model
Creating Fluent Migrations
Using Fluent Model Helpers
Implementing CRUD operations for Vapor
Implementing the create operation
Implementing the read operation
Implementing the update operation
Implementing the delete operation
Working with the Database Abstraction Layer in Kitura
Choosing a database driver
Using the PostgreSQL database driver
Setting up the SQLite database driver
Using the MySQL database driver
Conforming to the Swift-Kuery-ORM Model
Creating a new model
Implementing the CRUD operations
Displaying all records
Displaying a single record
Creating a new record
Updating an existing record
Deleting a record
Summary
Adding Authentication
Introducing the authentication API for Vapor
Using web authentication
Setting up AuthenticationProvider
Configuring for SessionMiddleware
Constructing a Model
Accessing protected content
Adding public routes
Adding the login page
Checking login credentials
Logging out of the current session
Specifying protected routes
Using the authenticated state
Managing accounts
Listing all accounts
Adding a New Account
Removing an account
Seeding databases
Introducing authentication for Kitura
Setting up HTTP basic authentication
Constructing a Model
Using TypeSafe HTTP authentication
Summary
Understanding Technologies for Web Services
Serving clients with web services
Designing three-tier architecture for web service
The frontend layer
The application layer
The data storage layer
Reviewing HTTP protocols
Designing the cloud frontend with pattern
The backends for frontends pattern
API gateway
Encapsulating business logic into microservices
Implementing a microservice-oriented architecture
Designing microservice with key principles
Cloud deployment
Containing microservices with Docker
Continuously deploying to the cloud
Working with a sample workflow
Summary
Designing for API Gateway
Serving clients with the RESTful API
Understanding the server/client model based on HTTP
Designing the RESTful API
Identifying object models
Defining resource endpoints
Defining endpoints for top-level resources
Defining Endpoints for Sub-resources
Assigning HTTP methods
Browsing all journal entries
Creating a new journal entry
Getting a specific journal entry
Editing a specific journal entry
Deleting a specific journal entry
Implementing the endpoints and responses
Implementing Handlers for Public Routes
Implementing handlers for admin routes
Creating a new item
Retrieving an item by ID
Updating an item
Deleting an Item
Implementing API endpoints for Kitura
Creating a new project for the Kitura web service application
Working with the Kitural model
Setting up a database
Adding route handlers
Retrieving all items
Creating a new item
Retrieving an item by ID
Updating an item
Deleting an item
Deleting All items
Summary
Deploying to the Cloud
Deploying Vapor web service to Vapor Cloud
Checking out Vapor Cloud features
Database and Cache Support
Application Monitoring
Recurrent Job Scheduling
Accessible to File Storage and CDN Services
Zero-Downtime Deployment
Signing up Vapor Cloud
Deploying to Vapor Cloud
Using the Vapor Cloud commands
Creating Your First Deployment
Creating an Application from Git Remote
Working with Slug and Environment
Choosing a Replica Size and Database
Choosing a Build Type
Managing Your Cloud application
Getting live log output
Working with environment variables
Adding a custom domain
Scheduling a New cronjob
Deploying the Kitura web service to IBM Cloud
Working with an IBM Cloud Account
Registering for an Account on IBM Cloud
Working with the IBM Cloud Dashboard
Readying the Local System for IBM Cloud Deployment
Installing IBM Cloud Developer Tools
Using IBM Cloud Developer Tools
Creating a Kitura app that is deployable to IBM Cloud
Generating a Starter Kitura Web Application
Logging into IBM Cloud
Building Your App with the IBM Cloud Tool
Running the Kitura App in the Local Container
Deploying Your app
Summary
Developing an iPhone Client
Developing an iOS App for a server-side Swift application
Creating a new project
Creating a new TableViewController
Adding content to TableViewController
Preparing your data model
Configuring table properties
Adding a label to the prototype cell
Constructing route handlers for web services
Adding domain exceptions for App Transport Security
Testing the Vapor Server app
Running the iOS app
Adding a new entry to journal
Designing the user interface for a new entry
Using the Delegate Pattern
Hooking up new functionalities for UI items
Steps to Make Requests to the server
Preparing for Encoded JSON Data
Configuring an Upload Request
Starting an Upload Task
Putting Everything Together for the upload task
Finishing the CRUD operations
Editing an existing entry
Creating the EditEntry segue
Adding a new function to the delegate protocol
Making an HTTP PUT request
Configuring the user interface to edit an entry
Deleting an existing entry
Summary
Developing Microservices
Leveraging Microservices in Backend Applications
The microservice-oriented architecture
Design Principles of the Microservice Framework
Deploying a Containerized Application to a Cluster
Working with Containers and Orchestrations
Understanding the Container Deployment workflow
Publishing a Docker image to IBM Cloud Registry
Logging into IBM Cloud
Working with the Docker CLI
Tagging Your Docker Image
Deploying a Docker Image to IBM Cloud Registry
Creating a Cluster on IBM Cloud
Setting up the Kubernetes CLI
Downloading the Cluster Configuration
Creating a Deployment Using Container Registry
Exposing the deployment and launching the app
Summary
Vapor Boilerplate Project
Reviewing Vapor-generated files
Installing tree to view the file structure
Reviewing a Vapor project's file structure
Understanding the file structure in a Vapor project
Configuring Swift Package Manager
Package dependencies
Build targets
Starting with an 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
Kitura Boilerplate Project
Reviewing Kitura-generated files
Reviewing a Kitura project's file structure
Understanding the file structure in a Kitura project
Understanding generated sourcecode in Kitura
Configuring using Swift Package Manager (SPM)
Starting with the entry point
Declaring application classes
Handling errors
Setting up monitoring metrics
Setting up health check endpoints
Other Books You May Enjoy
Leave a review - let other readers know what you think
更新时间:2021-06-10 19:01:21