27 lines
979 B
Swift
27 lines
979 B
Swift
import Fluent
|
|
import FluentPostgresDriver
|
|
import Vapor
|
|
|
|
// configures your application
|
|
public func configure(_ app: Application) throws {
|
|
// uncomment to serve files from /Public folder
|
|
// app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
|
|
// using custom configuration
|
|
app.middleware.use(CORSMiddleware(configuration: .init(
|
|
allowedOrigin: .all,
|
|
allowedMethods: [.GET, .POST, .PUT, .OPTIONS, .DELETE, .PATCH],
|
|
allowedHeaders: [.accept, .authorization, .contentType, .origin, .xRequestedWith]
|
|
)))
|
|
app.databases.use(.postgres(
|
|
hostname: Environment.get("DATABASE_HOST") ?? "api.sledsoft.com",
|
|
username: Environment.get("DATABASE_USERNAME") ?? "cod",
|
|
password: Environment.get("DATABASE_PASSWORD") ?? "pw4cod",
|
|
database: Environment.get("DATABASE_NAME") ?? "cod_db"
|
|
), as: .psql)
|
|
|
|
app.migrations.add(CreateMatch())
|
|
|
|
// register routes
|
|
try routes(app)
|
|
}
|