Skip to content

Instantly share code, notes, and snippets.

@iband
Last active December 29, 2021 02:33
Show Gist options
  • Save iband/ae407d60ab4a3035d9f5aa011eaeafa6 to your computer and use it in GitHub Desktop.
Save iband/ae407d60ab4a3035d9f5aa011eaeafa6 to your computer and use it in GitHub Desktop.
import Vapor
public func configure(_ app: Application) throws {
// register routes
try routes(app)
}
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "App",
products: [
// ...
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
],
targets: [
// ...
]
)
import App
import Vapor
var env = try Environment.detect()
try LoggingSystem.bootstrap(from: &env)
let app = Application(env)
defer { app.shutdown() }
try configure(app)
try app.run()
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "App",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "App",
targets: ["App"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "App",
dependencies: []),
.testTarget(
name: "AppTests",
dependencies: ["App"]),
]
)
import Vapor
func routes(_ app: Application) throws {
app.get { req in
return "It works!"
}
}
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "App",
products: [ ... ],
dependencies: [ ... ],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "App",
dependencies: [
.product(name: "Vapor", package: "vapor"),
]),
.executableTarget(name: "Run", dependencies: ["App"]),
.testTarget(
name: "AppTests",
dependencies: ["App"]),
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment