This project was part of a live coding session held at Learn Swift Milan meetup in November 2017, meant to illustrate the basics of Vapor.
It's a demo implementation of a very simple backend API for managing EmojiPet
objects, as represented in JSON format as follows:
{
"name": "FailPanda",
"emoji": "🐼"
}
The project was created using Vapor v2.4.0.
- Install Vapor, as explained on its getting started page
- Build the project using
vapor build
- Run the server with
vapor run
If you want to generate an Xcode project, you can use the vapor xcode
command.
The REST API supports two endpoints:
GET /api/pets
: get the list of existing EmojiPetsPOST /api/pets
: create a new EmojiPet
The project includes an emojipets.playground
file, that shows how to decode a JSON response containing a list of EmojiPets using Swift 4's Codable.