commit bdbdcf20819d9afae96985dfe78d29a599feedbd Author: christophhagen Date: Sun May 17 20:01:30 2020 +0200 'created CapCollectorServer from template https://github.com/twostraws/vapor-clean' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd70574 --- /dev/null +++ b/.gitignore @@ -0,0 +1,68 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint +.DS_Store + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..cdd0a93 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) YOUR NAME HERE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Package.swift b/Package.swift new file mode 100755 index 0000000..78a0e15 --- /dev/null +++ b/Package.swift @@ -0,0 +1,16 @@ +// swift-tools-version:5.0 +import PackageDescription + +let package = Package( + name: "CapCollectorServer", + dependencies: [ + // 💧 A server-side Swift web framework. + .package(url: "https://github.com/vapor/vapor.git", .upToNextMinor(from: "3.3.0")), + ], + targets: [ + .target(name: "App", dependencies: ["Vapor"]), + .target(name: "Run", dependencies: ["App"]), + .testTarget(name: "AppTests", dependencies: ["App"]), + ] +) + diff --git a/Public/.gitkeep b/Public/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100755 index 0000000..cd151d6 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Vapor Clean + +This is a template for Vapor 3 users that does the absolute minimum to set up a working Vapor 3 environment. + +Unlike the official templates that are currently available, this template does not include vast swathes of extra example code that you will always need to delete. Instead, it adds just a single “hello” route so you can be sure everything is working correctly. + +Although this repository contains a LICENSE file, this is meant for you to replace with whatever license you intend to use – please consider what little code is in this repository as public domain, and yours to do with as you please. + +It’s my hope that the official Vapor project will add a template similar to this one at some point in the future, but until then please use this however you want. + +## Try it out + +If you have already installed the Vapor toolbox, you can create a new Vapor project from this repo using the following command: + + vapor new MyProject --template=twostraws/vapor-clean diff --git a/Resources/Views/.gitkeep b/Resources/Views/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/Sources/App/boot.swift b/Sources/App/boot.swift new file mode 100755 index 0000000..382f98a --- /dev/null +++ b/Sources/App/boot.swift @@ -0,0 +1,9 @@ +import Routing +import Vapor + +/// Called after your application has initialized. +/// +/// [Learn More →](https://docs.vapor.codes/3.0/getting-started/structure/#bootswift) +public func boot(_ app: Application) throws { + // your code here +} diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift new file mode 100755 index 0000000..264849b --- /dev/null +++ b/Sources/App/configure.swift @@ -0,0 +1,17 @@ +import Vapor + +/// Called before your application initializes. +/// +/// [Learn More →](https://docs.vapor.codes/3.0/getting-started/structure/#configureswift) +public func configure( + _ config: inout Config, + _ env: inout Environment, + _ services: inout Services +) throws { + // Register routes to the router + let router = EngineRouter.default() + try routes(router) + services.register(router, as: Router.self) + + // Configure the rest of your application here +} diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift new file mode 100755 index 0000000..41fd993 --- /dev/null +++ b/Sources/App/routes.swift @@ -0,0 +1,11 @@ +import Routing +import Vapor + +/// Register your application's routes here. +/// +/// [Learn More →](https://docs.vapor.codes/3.0/getting-started/structure/#routesswift) +public func routes(_ router: Router) throws { + router.get("hello") { req in + return "Hello, world!" + } +} diff --git a/Sources/Run/main.swift b/Sources/Run/main.swift new file mode 100755 index 0000000..e7416b7 --- /dev/null +++ b/Sources/Run/main.swift @@ -0,0 +1,26 @@ +import App +import Service +import Vapor +import Foundation + +// The contents of main are wrapped in a do/catch block because any errors that get raised to the top level will crash Xcode +do { + var config = Config.default() + var env = try Environment.detect() + var services = Services.default() + + try App.configure(&config, &env, &services) + + let app = try Application( + config: config, + environment: env, + services: services + ) + + try App.boot(app) + + try app.run() +} catch { + print(error) + exit(1) +} diff --git a/Tests/.gitkeep b/Tests/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/Tests/AppTests/AppTests.swift b/Tests/AppTests/AppTests.swift new file mode 100755 index 0000000..cfce2e4 --- /dev/null +++ b/Tests/AppTests/AppTests.swift @@ -0,0 +1,13 @@ +import App +import Dispatch +import XCTest + +final class AppTests : XCTestCase { + func testNothing() throws { + XCTAssert(true) + } + + static let allTests = [ + ("testNothing", testNothing), + ] +} diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100755 index 0000000..e69de29 diff --git a/circle.yml b/circle.yml new file mode 100755 index 0000000..035a42c --- /dev/null +++ b/circle.yml @@ -0,0 +1,25 @@ +version: 2 + +jobs: + macos: + macos: + xcode: "9.2" + steps: + - checkout + - run: swift build + - run: swift test + linux: + docker: + - image: norionomura/swift:swift-4.1-branch + steps: + - checkout + - run: apt-get update + - run: apt-get install -yq libssl-dev + - run: swift build + - run: swift test +workflows: + version: 2 + tests: + jobs: + - linux + # - macos diff --git a/cloud.yml b/cloud.yml new file mode 100755 index 0000000..b53f575 --- /dev/null +++ b/cloud.yml @@ -0,0 +1,3 @@ +type: "vapor" +swift_version: "4.2.0" +run_parameters: "serve --port 8080 --hostname 0.0.0.0"