Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vapor-community/todo-example

An example implementation for http://todobackend.com
https://github.com/vapor-community/todo-example

Last synced: about 2 months ago
JSON representation

An example implementation for http://todobackend.com

Awesome Lists containing this project

README

        

# 📔 Vapor Todo Backend

Run the specs [here](https://vapor-todo.herokuapp.com/)

[Vapor](https://github.com/vapor/vapor) is a Swift backend framework to build server-side applications in Swift.

[TodoBackend](http://www.todobackend.com) 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](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/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`

```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

```sh
brew install vapor/tap/toolbox
```

#### Curl

```sh
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](https://vapor.github.io/documentation/)

## 🙌 Thanks

A great deal of work on this library was originally done by @sarbogast. Thanks 🙌