Update routes.swift

This commit is contained in:
christophhagen 2020-05-19 16:13:13 +02:00
parent aa5ee6ee70
commit 75f40e9c9e

View File

@ -2,18 +2,26 @@ import Routing
import Vapor import Vapor
import SQLite import SQLite
private let fm = FileManager.default // MARK: Paths
private let baseFolder = URL(fileURLWithPath: "/caps") private let baseFolder = URL(fileURLWithPath: "/caps")
private let imageFolder = URL(fileURLWithPath: "/caps/Public/images") private let publicFolder = baseFolder.appendingPathComponent("Public")
private let dbFile = "/caps/db.sqlite3" private let imageFolder = publicFolder.appendingPathComponent("images")
private let tempImageFile = imageFolder.appendingPathComponent("temp.jpg") private let dbFile = publicFolder.appendingPathComponent("db.sqlite3").path
private let tempImageFile = publicFolder.appendingPathComponent("temp.jpg")
// MARK: Variables
private let fm = FileManager.default
private var db: Connection! private var db: Connection!
// MARK: SQLite
private let id = Expression<Int>("id") private let id = Expression<Int>("id")
private let name = Expression<String>("name") private let name = Expression<String>("name")
@ -24,6 +32,8 @@ func loadDatabase() throws {
db = try Connection(dbFile) db = try Connection(dbFile)
} }
// MARK: Helper
private func select(_ cap: Int) -> Table { private func select(_ cap: Int) -> Table {
table.filter(id == cap) table.filter(id == cap)
} }
@ -48,6 +58,8 @@ private func count(of cap: Int) throws -> Int {
return try countImages(in: f) return try countImages(in: f)
} }
// MARK: Routes
/// Register your application's routes here. /// Register your application's routes here.
/// ///
/// [Learn More ](https://docs.vapor.codes/3.0/getting-started/structure/#routesswift) /// [Learn More ](https://docs.vapor.codes/3.0/getting-started/structure/#routesswift)