-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'created Hello from template https://github.com/vapor/api-template'
- Loading branch information
0 parents
commit 5227b68
Showing
22 changed files
with
476 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
version: 2 | ||
|
||
jobs: | ||
linux: | ||
docker: | ||
- image: swift:4.1 | ||
steps: | ||
- checkout | ||
- run: | ||
name: Compile code | ||
command: swift build | ||
- run: | ||
name: Run unit tests | ||
command: swift test | ||
|
||
linux-release: | ||
docker: | ||
- image: swift:4.1 | ||
steps: | ||
- checkout | ||
- run: | ||
name: Compile code with optimizations | ||
command: swift build -c release | ||
|
||
workflows: | ||
version: 2 | ||
tests: | ||
jobs: | ||
- linux | ||
- linux-release | ||
|
||
nightly: | ||
triggers: | ||
- schedule: | ||
cron: "0 0 * * *" | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
jobs: | ||
- linux | ||
- linux-release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.git | ||
.build | ||
DerivedData | ||
Package.resolved | ||
*.xcodeproj | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Packages | ||
.build | ||
xcuserdata | ||
*.xcodeproj | ||
DerivedData/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Contributing to Vapor API Template | ||
|
||
If you found a mistake or think of a cool new feature, please [create an issue](https://github.com/vapor/api-template/issues/new) or, if you want to implement it yourself, [fork this repo](https://github.com/vapor/api-template/fork) and open a Pull Request! | ||
|
||
We'll take a look as soon as we can. | ||
|
||
Thanks! | ||
|
||
## Maintainers | ||
|
||
- [@0xTim](https://github.com/0xTim) | ||
|
||
See the [Vapor maintainers doc](https://github.com/vapor/vapor/blob/master/Docs/maintainers.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "Console", | ||
"repositoryURL": "https://github.com/vapor/console.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "74cfbea629d4aac34a97cead2447a6870af1950b", | ||
"version": "3.1.1" | ||
} | ||
}, | ||
{ | ||
"package": "Core", | ||
"repositoryURL": "https://github.com/vapor/core.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "727ae2905ebdca162c5da5bfe187c406555859e2", | ||
"version": "3.7.3" | ||
} | ||
}, | ||
{ | ||
"package": "Crypto", | ||
"repositoryURL": "https://github.com/vapor/crypto.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "45bb12d13cdec80dbd1cc0685ea002e51ab83439", | ||
"version": "3.3.2" | ||
} | ||
}, | ||
{ | ||
"package": "DatabaseKit", | ||
"repositoryURL": "https://github.com/vapor/database-kit.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "8f352c8e66dab301ab9bfef912a01ce1361ba1e4", | ||
"version": "1.3.3" | ||
} | ||
}, | ||
{ | ||
"package": "Fluent", | ||
"repositoryURL": "https://github.com/vapor/fluent.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "3776a0f623e08b413e878f282a70e8952651c91f", | ||
"version": "3.1.3" | ||
} | ||
}, | ||
{ | ||
"package": "FluentSQLite", | ||
"repositoryURL": "https://github.com/vapor/fluent-sqlite.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "c32f5bda84bf4ea691d19afe183d40044f579e11", | ||
"version": "3.0.0" | ||
} | ||
}, | ||
{ | ||
"package": "HTTP", | ||
"repositoryURL": "https://github.com/vapor/http.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "8da7d475a1a060714766d9ad4b24eb0dae243aab", | ||
"version": "3.1.11" | ||
} | ||
}, | ||
{ | ||
"package": "Multipart", | ||
"repositoryURL": "https://github.com/vapor/multipart.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "bd7736c5f28e48ed8b683dcc9df3dcd346064c2b", | ||
"version": "3.0.3" | ||
} | ||
}, | ||
{ | ||
"package": "Routing", | ||
"repositoryURL": "https://github.com/vapor/routing.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "626190ddd2bd9f967743b60ba6adaf90bbd2651c", | ||
"version": "3.0.2" | ||
} | ||
}, | ||
{ | ||
"package": "Service", | ||
"repositoryURL": "https://github.com/vapor/service.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "fa5b5de62bd68bcde9a69933f31319e46c7275fb", | ||
"version": "1.0.2" | ||
} | ||
}, | ||
{ | ||
"package": "SQL", | ||
"repositoryURL": "https://github.com/vapor/sql.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "50eaeb8f52a1ce63f1ff3880e1114dd8757a78a6", | ||
"version": "2.3.2" | ||
} | ||
}, | ||
{ | ||
"package": "SQLite", | ||
"repositoryURL": "https://github.com/vapor/sqlite.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "314d9cd21165bcf14215e336a23ff8214f40e411", | ||
"version": "3.2.1" | ||
} | ||
}, | ||
{ | ||
"package": "swift-nio", | ||
"repositoryURL": "https://github.com/apple/swift-nio.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "29a9f2aca71c8afb07e291336f1789337ce235dd", | ||
"version": "1.13.2" | ||
} | ||
}, | ||
{ | ||
"package": "swift-nio-ssl", | ||
"repositoryURL": "https://github.com/apple/swift-nio-ssl.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "0f3999f3e3c359cc74480c292644c3419e44a12f", | ||
"version": "1.4.0" | ||
} | ||
}, | ||
{ | ||
"package": "swift-nio-ssl-support", | ||
"repositoryURL": "https://github.com/apple/swift-nio-ssl-support.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "c02eec4e0e6d351cd092938cf44195a8e669f555", | ||
"version": "1.0.0" | ||
} | ||
}, | ||
{ | ||
"package": "swift-nio-zlib-support", | ||
"repositoryURL": "https://github.com/apple/swift-nio-zlib-support.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "37760e9a52030bb9011972c5213c3350fa9d41fd", | ||
"version": "1.0.0" | ||
} | ||
}, | ||
{ | ||
"package": "TemplateKit", | ||
"repositoryURL": "https://github.com/vapor/template-kit.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "4b1073d74be9f5c6a5bc63a07a84e83efec26229", | ||
"version": "1.1.2" | ||
} | ||
}, | ||
{ | ||
"package": "URLEncodedForm", | ||
"repositoryURL": "https://github.com/vapor/url-encoded-form.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "82d8d63bdb76b6dd8febe916c639ab8608dbbaed", | ||
"version": "1.0.6" | ||
} | ||
}, | ||
{ | ||
"package": "Validation", | ||
"repositoryURL": "https://github.com/vapor/validation.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "4de213cf319b694e4ce19e5339592601d4dd3ff6", | ||
"version": "2.1.1" | ||
} | ||
}, | ||
{ | ||
"package": "Vapor", | ||
"repositoryURL": "https://github.com/vapor/vapor.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "c86ada59b31c69f08a6abd4f776537cba48d5df6", | ||
"version": "3.3.0" | ||
} | ||
}, | ||
{ | ||
"package": "WebSocket", | ||
"repositoryURL": "https://github.com/vapor/websocket.git", | ||
"state": { | ||
"branch": null, | ||
"revision": "d85e5b6dce4d04065865f77385fc3324f98178f6", | ||
"version": "1.1.2" | ||
} | ||
} | ||
] | ||
}, | ||
"version": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// swift-tools-version:4.0 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Hello", | ||
products: [ | ||
.library(name: "Hello", targets: ["App"]), | ||
], | ||
dependencies: [ | ||
// 💧 A server-side Swift web framework. | ||
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"), | ||
|
||
// 🔵 Swift ORM (queries, models, relations, etc) built on SQLite 3. | ||
.package(url: "https://github.com/vapor/fluent-sqlite.git", from: "3.0.0") | ||
], | ||
targets: [ | ||
.target(name: "App", dependencies: ["FluentSQLite", "Vapor"]), | ||
.target(name: "Run", dependencies: ["App"]), | ||
.testTarget(name: "AppTests", dependencies: ["App"]) | ||
] | ||
) | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<p align="center"> | ||
<img src="https://user-images.githubusercontent.com/1342803/36623515-7293b4ec-18d3-11e8-85ab-4e2f8fb38fbd.png" width="320" alt="API Template"> | ||
<br> | ||
<br> | ||
<a href="http://docs.vapor.codes/3.0/"> | ||
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation"> | ||
</a> | ||
<a href="https://discord.gg/vapor"> | ||
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat"> | ||
</a> | ||
<a href="LICENSE"> | ||
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License"> | ||
</a> | ||
<a href="https://circleci.com/gh/vapor/api-template"> | ||
<img src="https://circleci.com/gh/vapor/api-template.svg?style=shield" alt="Continuous Integration"> | ||
</a> | ||
<a href="https://swift.org"> | ||
<img src="http://img.shields.io/badge/swift-4.1-brightgreen.svg" alt="Swift 4.1"> | ||
</a> | ||
</p> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Vapor | ||
|
||
/// Controls basic CRUD operations on `Todo`s. | ||
final class TodoController { | ||
/// Returns a list of all `Todo`s. | ||
func index(_ req: Request) throws -> Future<[Todo]> { | ||
return Todo.query(on: req).all() | ||
} | ||
|
||
/// Saves a decoded `Todo` to the database. | ||
func create(_ req: Request) throws -> Future<Todo> { | ||
return try req.content.decode(Todo.self).flatMap { todo in | ||
return todo.save(on: req) | ||
} | ||
} | ||
|
||
/// Deletes a parameterized `Todo`. | ||
func delete(_ req: Request) throws -> Future<HTTPStatus> { | ||
return try req.parameters.next(Todo.self).flatMap { todo in | ||
return todo.delete(on: req) | ||
}.transform(to: .ok) | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import FluentSQLite | ||
import Vapor | ||
|
||
/// A single entry of a Todo list. | ||
final class Todo: SQLiteModel { | ||
/// The unique identifier for this `Todo`. | ||
var id: Int? | ||
|
||
/// A title describing what this `Todo` entails. | ||
var title: String | ||
|
||
/// Creates a new `Todo`. | ||
init(id: Int? = nil, title: String) { | ||
self.id = id | ||
self.title = title | ||
} | ||
} | ||
|
||
/// Allows `Todo` to be used as a dynamic migration. | ||
extension Todo: Migration { } | ||
|
||
/// Allows `Todo` to be encoded to and decoded from HTTP messages. | ||
extension Todo: Content { } | ||
|
||
/// Allows `Todo` to be used as a dynamic parameter in route definitions. | ||
extension Todo: Parameter { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Vapor | ||
|
||
/// Creates an instance of `Application`. This is called from `main.swift` in the run target. | ||
public func app(_ env: Environment) throws -> Application { | ||
var config = Config.default() | ||
var env = env | ||
var services = Services.default() | ||
try configure(&config, &env, &services) | ||
let app = try Application(config: config, environment: env, services: services) | ||
try boot(app) | ||
return app | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Vapor | ||
|
||
/// Called after your application has initialized. | ||
public func boot(_ app: Application) throws { | ||
// Your code here | ||
} |
Oops, something went wrong.