'created smparkinVaporWeb from template https://github.com/vapor/web-template'
This commit is contained in:
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/vapor
|
||||
|
||||
### Vapor ###
|
||||
Config/secrets
|
||||
|
||||
### Vapor Patch ###
|
||||
Packages
|
||||
.build
|
||||
xcuserdata
|
||||
*.xcodeproj
|
||||
DerivedData/
|
||||
.DS_Store
|
||||
|
||||
# End of https://www.gitignore.io/api/vapor
|
||||
13
CONTRIBUTING.md
Normal file
13
CONTRIBUTING.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Contributing to Vapor Web Template
|
||||
|
||||
If you found a mistake or think of a cool new feature, please [create an issue](https://github.com/vapor/web-template/issues/new) or, if you want to implement it yourself, [fork this repo](https://github.com/vapor/web-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.
|
||||
169
Package.resolved
Normal file
169
Package.resolved
Normal file
@@ -0,0 +1,169 @@
|
||||
{
|
||||
"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": "57368d4092f92df3131e5968c8ed24a3c7361ec0",
|
||||
"version": "3.8.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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": "HTTP",
|
||||
"repositoryURL": "https://github.com/vapor/http.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "254a0a0cbf22a02b697a075a0d2ddbb448bb7c87",
|
||||
"version": "3.2.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Leaf",
|
||||
"repositoryURL": "https://github.com/vapor/leaf.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "d35f54cbac723e673f9bd5078361eea74049c8d7",
|
||||
"version": "3.0.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"package": "Multipart",
|
||||
"repositoryURL": "https://github.com/vapor/multipart.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "f919a01c4d10a281d6236a21b0b1d1759a72b8eb",
|
||||
"version": "3.0.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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": "swift-nio",
|
||||
"repositoryURL": "https://github.com/apple/swift-nio.git",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "ba7970fe396e8198b84c6c1b44b38a1d4e2eb6bd",
|
||||
"version": "1.14.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
19
Package.swift
Normal file
19
Package.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
// swift-tools-version:4.0
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "smparkinVaporWeb",
|
||||
dependencies: [
|
||||
// 💧 A server-side Swift web framework.
|
||||
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
|
||||
|
||||
// 🍃 An expressive, performant, and extensible templating language built for Swift.
|
||||
.package(url: "https://github.com/vapor/leaf.git", from: "3.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "App", dependencies: ["Leaf", "Vapor"]),
|
||||
.target(name: "Run", dependencies: ["App"]),
|
||||
.testTarget(name: "AppTests", dependencies: ["App"])
|
||||
]
|
||||
)
|
||||
|
||||
0
Public/.gitkeep
Normal file
0
Public/.gitkeep
Normal file
BIN
Public/images/it-works.png
Normal file
BIN
Public/images/it-works.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
19
Public/styles/app.css
Normal file
19
Public/styles/app.css
Normal file
@@ -0,0 +1,19 @@
|
||||
body, html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
div.welcome {
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.welcome img {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 300px;
|
||||
}
|
||||
20
README.md
Normal file
20
README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/1342803/43869499-ce6ce122-9b40-11e8-8894-e0c48eabf270.png" width="320" alt="Web 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/web-template">
|
||||
<img src="https://circleci.com/gh/vapor/web-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>
|
||||
10
Resources/Views/base.leaf
Normal file
10
Resources/Views/base.leaf
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>#get(title)</title>
|
||||
<link rel="stylesheet" href="/styles/app.css">
|
||||
</head>
|
||||
<body>
|
||||
#get(body)
|
||||
</body>
|
||||
</html>
|
||||
7
Resources/Views/hello.leaf
Normal file
7
Resources/Views/hello.leaf
Normal file
@@ -0,0 +1,7 @@
|
||||
#set("title") { Hello, #(name)! }
|
||||
|
||||
#set("body") {
|
||||
<h1>Hello, #(name)!</h1>
|
||||
}
|
||||
|
||||
#embed("base")
|
||||
9
Resources/Views/welcome.leaf
Normal file
9
Resources/Views/welcome.leaf
Normal file
@@ -0,0 +1,9 @@
|
||||
#set("title") { It works }
|
||||
|
||||
#set("body") {
|
||||
<div class="welcome">
|
||||
<img src="/images/it-works.png">
|
||||
</div>
|
||||
}
|
||||
|
||||
#embed("base")
|
||||
0
Sources/App/Controllers/.gitkeep
Normal file
0
Sources/App/Controllers/.gitkeep
Normal file
0
Sources/App/Models/.gitkeep
Normal file
0
Sources/App/Models/.gitkeep
Normal file
12
Sources/App/app.swift
Normal file
12
Sources/App/app.swift
Normal file
@@ -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
|
||||
}
|
||||
6
Sources/App/boot.swift
Normal file
6
Sources/App/boot.swift
Normal file
@@ -0,0 +1,6 @@
|
||||
import Vapor
|
||||
|
||||
/// Called after your application has initialized.
|
||||
public func boot(_ app: Application) throws {
|
||||
// Your code here
|
||||
}
|
||||
22
Sources/App/configure.swift
Normal file
22
Sources/App/configure.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
import Leaf
|
||||
import Vapor
|
||||
|
||||
/// Called before your application initializes.
|
||||
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {
|
||||
// Register providers first
|
||||
try services.register(LeafProvider())
|
||||
|
||||
// Register routes to the router
|
||||
let router = EngineRouter.default()
|
||||
try routes(router)
|
||||
services.register(router, as: Router.self)
|
||||
|
||||
// Use Leaf for rendering views
|
||||
config.prefer(LeafRenderer.self, for: ViewRenderer.self)
|
||||
|
||||
// Register middleware
|
||||
var middlewares = MiddlewareConfig() // Create _empty_ middleware config
|
||||
middlewares.use(FileMiddleware.self) // Serves files from `Public/` directory
|
||||
middlewares.use(ErrorMiddleware.self) // Catches errors and converts to HTTP response
|
||||
services.register(middlewares)
|
||||
}
|
||||
16
Sources/App/routes.swift
Normal file
16
Sources/App/routes.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
import Vapor
|
||||
|
||||
/// Register your application's routes here.
|
||||
public func routes(_ router: Router) throws {
|
||||
// "It works" page
|
||||
router.get { req in
|
||||
return try req.view().render("welcome")
|
||||
}
|
||||
|
||||
// Says hello
|
||||
router.get("hello", String.parameter) { req -> Future<View> in
|
||||
return try req.view().render("hello", [
|
||||
"name": req.parameters.next(String.self)
|
||||
])
|
||||
}
|
||||
}
|
||||
3
Sources/Run/main.swift
Normal file
3
Sources/Run/main.swift
Normal file
@@ -0,0 +1,3 @@
|
||||
import App
|
||||
|
||||
try app(.detect()).run()
|
||||
12
Tests/AppTests/AppTests.swift
Normal file
12
Tests/AppTests/AppTests.swift
Normal file
@@ -0,0 +1,12 @@
|
||||
import XCTest
|
||||
@testable import App
|
||||
|
||||
class AppTests: XCTestCase {
|
||||
func testStub() throws {
|
||||
XCTAssert(true)
|
||||
}
|
||||
|
||||
static let allTests = [
|
||||
("testStub", testStub),
|
||||
]
|
||||
}
|
||||
11
Tests/LinuxMain.swift
Normal file
11
Tests/LinuxMain.swift
Normal file
@@ -0,0 +1,11 @@
|
||||
#if os(Linux)
|
||||
|
||||
import XCTest
|
||||
@testable import AppTests
|
||||
|
||||
XCTMain([
|
||||
// AppTests
|
||||
testCase(AppTests.allTests),
|
||||
])
|
||||
|
||||
#endif
|
||||
43
circle.yml
Normal file
43
circle.yml
Normal file
@@ -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
|
||||
|
||||
30
web.Dockerfile
Normal file
30
web.Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
||||
# You can set the Swift version to what you need for your app. Versions can be found here: https://hub.docker.com/_/swift
|
||||
FROM swift:5.0 as builder
|
||||
|
||||
# For local build, add `--build-arg env=docker`
|
||||
# In your application, you can use `Environment.custom(name: "docker")` to check if you're in this env
|
||||
ARG env
|
||||
|
||||
RUN apt-get -qq update && apt-get install -y \
|
||||
libssl-dev zlib1g-dev \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN mkdir -p /build/lib && cp -R /usr/lib/swift/linux/*.so* /build/lib
|
||||
RUN swift build -c release && mv `swift build -c release --show-bin-path` /build/bin
|
||||
|
||||
# Production image
|
||||
FROM ubuntu:18.04
|
||||
ARG env
|
||||
# DEBIAN_FRONTEND=noninteractive for automatic UTC configuration in tzdata
|
||||
RUN apt-get -qq update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
libatomic1 libicu60 libxml2 libcurl4 libz-dev libbsd0 tzdata \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
WORKDIR /app
|
||||
COPY --from=builder /build/bin/Run .
|
||||
COPY --from=builder /build/lib/* /usr/lib/
|
||||
COPY --from=builder /app/Public ./Public
|
||||
COPY --from=builder /app/Resources ./Resources
|
||||
ENV ENVIRONMENT=$env
|
||||
|
||||
ENTRYPOINT ./Run serve --env $ENVIRONMENT --hostname 0.0.0.0 --port 80
|
||||
Reference in New Issue
Block a user