Todos API using Vapor3 and Swift4
This repo is a part of my full-stack Swift tutorial:
- VaporTodos-API Vapor API (this repo)
- VaporTodos-iOS iOS Application
a. For Ubuntu
eval "$(curl -sL https://apt.vapor.sh)"
sudo apt-get install swift vapor
eval "$(curl -sL check.vapor.sh)"
b. For macOS
brew install vapor
vapor build
Please be patient, this might take several minutes for the first build 😅
vapor xcode -y
vapor run
Endpoint | Method | Description | Authorization Type |
---|---|---|---|
api/auth/register |
POST |
Create new account | None |
api/auth/login |
POST |
Get access token | Basic |
api/users |
GET |
Get a list of users | Bearer |
api/users |
PUT |
Update current user info | Bearer |
api/todos |
POST |
Create new todo item | Bearer |
api/todos |
GET |
Get all user's todo items | Bearer |
api/todos/<id> |
GET |
Get todo item | Bearer |
api/todos/<id> |
PUT |
Update todo item | Bearer |
api/todos/<id> |
DELETE |
Delete todo item | Bearer |
- Models
PublicType.swift
protocol used to create Public responses for models.Token.swift
Token model.User.swift
User model.Todo.swift
Todo model.
- Controllers
AuthController.swift
handles creating users and logging in.TodoController.swift
handles CRUD operations on Todo items.UserController.swift
handles listing user's todo items.
Path.swift
URL pathes used in controllers.- Vapor Files automatically created by Vapor.
app.swift
boot.swift
configure.swift
routes.swift
- Vapor 3
- Linux Ubuntu 14.04+ / macOS with Xcode 9.3+
- Swift 4+
VaporTodos is released under the MIT license. See LICENSE for more information.