hsalazr / todo-example

An example implementation for http://todobackend.com

Home Page:https://vapor-todo.herokuapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ“” Vapor Todo Backend

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.

🌎 Environment

  • Swift 3.0 Gold Master
  • MySQL Database Credentials

πŸ¦„ Deploy

Fully deploy w/ MySQL Database included on Heroku.

Deploy

πŸ›  Setup

Swift 3.0

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

MySQL Config

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"
}

Vapor CLI

The Vapor Command Line Interface makes it easy to build and run Vapor projects. Install it on Mac by running

Brew

brew install vapor/tap/toolbox

Curl

curl -sL toolbox.vapor.sh | bash

Manual Deploy

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.

mysql.json

{
  "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

πŸ™Œ Thanks

A great deal of work on this library was originally done by @sarbogast. Thanks πŸ™Œ

About

An example implementation for http://todobackend.com

https://vapor-todo.herokuapp.com

License:MIT License


Languages

Language:Swift 86.8%Language:CSS 13.2%