Run the specs here
Vapor is a Swift backend framework to build server-side applications in Swift.
TodoBackend is a proof-of-concept catalog to demonstrate the implementation of the same simple API using different backend frameworks.
This project is a TodoBackend implementation using Vapor, Swift and MySQL as a backend stack.
- Swift 3.0 Gold Master
- MySQL Database Credentials
Fully deploy w/ MySQL Database included on Heroku.
Download latest Xcode 8 and make sure it's been opened at least once. Also make sure command line tools are set to Xcode 8 in Xcode's preferences.
Xcode > Preferences > Locations > Command Line Tools
To build, the first place you'll want to look is the Config/
directory. In their, you should create a secrets
folder and a nested mysql.json
. Here's how my Config/
folder looks locally.
Config/
- mysql.json
secrets/
- mysql.json
The secrets
folder is under the gitignore and shouldn't be committed.
Here's an example secrets/mysql.json
{
"host": "z99a0.asdf8c8cx.us-east-1.rds.amazonaws.com",
"user": "username",
"password": "badpassword",
"database": "databasename",
"port": "3306",
"encoding": "utf8"
}
The Vapor Command Line Interface makes it easy to build and run Vapor projects. Install it on Mac by running
brew install vapor/tap/toolbox
curl -sL toolbox.vapor.sh | bash
When deploying, one may optionally include the secrets
folder if they have a secure way of doing so. The official deploy is done through use of environment variables configured on the server that match the following scheme.
{
"host": "$MYSQL_HOST",
"user": "$MYSQL_USER",
"password": "$MYSQL_PASS",
"database": "$MYSQL_DB",
"port": "$MYSQL_PORT",
"encoding": "utf8"
}
// OR
{
"url": "mysql://user:pass@host:3306/database"
}
Checkout more documentation here
A great deal of work on this library was originally done by @sarbogast. Thanks 🙌