Hi all,
New to Vaporā¦ Semi-new to Swift but making good progress (so I think)
Went and followed the tutorial on getting HelloVapor up and running. all good.
Followed another bit of document about adding a Config/server.json for a custom hostname and port number - and then settled on perhaps that just doesnāt work.
Then I saw;
http://beta.docs.vapor.codes/settings/config/#quickstart
and I was keen to try out custom configsā¦ so I created a test.json file
{
ātestConfigā: āsome value hereā,
}
and then I added this to some code.
let customValue = drop.config[āserversā, ātestConfigā]?.string ?? ādefaultā
This didnāt compileā¦ not surprised.
I then realised that I donāt have any variable called ādropā. I then realised that one of the first tutorials I saw created a Droplet instance called drop.
https://www.raywenderlich.com/5023-server-side-swift-with-vapor-getting-started
BUT the HelloVapor project I had created using a different tutorial didnāt do that at all. Confusion ensured. No such Droplet instance at all. just a public function app with a load of variables and initialisation in it.
So a couple of questionsā¦ how come there are different approaches ā¦ both tutorials created a new project (AFAIK) using the same vapor new xx command and vapor xcode etc commands. One creates a new instance of Droplet and the other does not at all.
Next questionā¦
The documentation for āconfigā says "For Vapor applications, configuration files are expected to be nested under a top level folder named Config
So I created a folder in my Xcode project called Config and then the xxx.json file etc. For some reason I just knew this probably wasnāt right but didnāt know what else that meant.
So - where is this Config folder structure suppose to be? and for a bonus point - how am I suppose to access .config method to read my custom settings from the config file.
Hope someone can helpā¦
ps. I have official Vapor book on routeā¦