diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift index a3946e6..ab3d9d5 100755 --- a/Sources/App/routes.swift +++ b/Sources/App/routes.swift @@ -2,18 +2,26 @@ import Routing import Vapor import SQLite -private let fm = FileManager.default +// MARK: Paths 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! +// MARK: SQLite + private let id = Expression("id") private let name = Expression("name") @@ -24,6 +32,8 @@ func loadDatabase() throws { db = try Connection(dbFile) } +// MARK: Helper + private func select(_ cap: Int) -> Table { table.filter(id == cap) } @@ -48,6 +58,8 @@ private func count(of cap: Int) throws -> Int { return try countImages(in: f) } +// MARK: Routes + /// Register your application's routes here. /// /// [Learn More →](https://docs.vapor.codes/3.0/getting-started/structure/#routesswift)