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;
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.
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.
The documentation for ‘config’ says "For Vapor applications, configuration files are expected to be nested under a top level folder named
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…