Server Side Swift with Vapor - Part 1: Introduction | Ray Wenderlich

In this video, you'll learn about Vapor and find out what you'll be learning throughout this course.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4493-server-side-swift-with-vapor/lessons/1

Hi Tim, I appreciate the time you take out of your day to respond. My reddit name is ilovecaketoomuch.

1/ I had to dig for the docs. Perhaps put a link to the official docs? https://docs.vapor.codes/3.0/
2/ I followed along, and it worked out. The challenges are great, maybe a few more would be dandy.
3/ Accepting Data section, how does it figure out to send the http header ‘application/json’, etc?
4/ How do a group a route? pseudo example route like below
Group(“auth”) {
post(“register”) { … }
pos(“login”) {…}
}

Not part of the videos

4/ One of the difficulties I had, not part of the lesson, was adding a controller. In Xcode, I needed to add it to the AppFramework(???) but accidentally added it to the Framework. Still bit confused about that, why it just did not automatically pickup the new controller in the folder.
5/ Async looks awful to use. I am spending time today trying to figure it all out. Futures/Promises.

Warm Regards,

ILoveFreakingLemonCakeTooMuch

@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]

@zsxawerdu thanks for trying it out!

1 - Docs is a good idea, I’ll add a link somewhere. Unfortunately the docs are massively outdated at the moment, but they’re slowly getting fixed
2 - glad to hear it!
3 - if you set the data to JSON-encoded in Rested it sets that header
4 - to group a route do router.grouped() - that’s coming up in the next section
4b - welcome to SPM world! The Xcode project is discardable so you need to regenerate it whenever you add files or make sure you select the correct target if adding via Xcode. Unfortunately Xcode isn’t very clever with this at the moment. Creating a controller is covered in the next section
5 - async is a learning curve, but once you understand it it’s ok. It’s covered in later videos again

The next set of videos were due to be out but unfortunately I’ve had to re-record them due to some fundamental changes in the beta. I’m getting them done ASAP!

@0xtim Really enjoying this series of videos. Thanks for doing them. Two things I don’t see in your list of planned videos that I’m hoping you’ll cover:

  1. Deploying to a private server. Most clients already have their own boxes and don’t want Heroku or things like that.
  2. Working with existing databases where this API doesn’t “own” the database.

@gargoyle unfortunately there wasn’t time to fit everything in for the videos so neither of those will be covered. (Though using models that aren’t prepared by Vapor is sort of covered in the Authentication videos)

Both topics should be covered in the book however

I need the same topics covered as well!

Hey @0xtim - just wanted to say I absolutely love the series! Thanks!

1 Like

Hi @0xtim, I installed Xcode 9.3 and the latest Vapor 3.0.0.rc2.2.1 and try to run the above examples. I experience a problem with OpenSSL, it can’t open ‘openssl/conf.h’ during compilation? Any clue how to fix this in Xcode. I already installed openssl with Brew.

@boersma that’s not the most helpful error but you need to install LibreSSL. Either upgrade the toolbox or run brew install libressl

Hi @0xtim, this works. Thanks, I also had to add a couple of try’s and an import of “Random” instead of “Crypto” in Token.swift and than it works fine. Very nice to see it working with swift-nio :smile:

@boersma yeah there were a few changes introduced in RC2 mainly because of NIO. The full list is here https://gist.github.com/0xTim/b372f91c8bd71ea757d1da526058f2d9#file-notes-md

I think those 2 topics that @gargoyle mentioned are the most wanted by any developer and it’s hardly covered by any Vapor tutorials. It should be on the video tutorial as well.

@ffabri I had to cut a load of stuff out of the videos and even then everything barely fit. Hopefully the book and online tutorials as Vapor stabilises will cover the missing parts!

Hi I need to know if it is possible to run a swift web services in a local system and have it work with a mobile app , with out actually deploying it to the actual server .

Hi @sarathy - when you say local system what do you mean exactly? On a local network on or the phone?

Yes on a local network . For example if i develop a API using SWIFT and before i copy the files to the server , Is it possible to run the API From my system so that i can access the API from a mobile App .

@sarathy yep you can run a Vapor app anywhere, including in Xcode. The only thing you’ll need to change is the hostname to allow other IP addresses to connect to it (other than localhost)

What about using perfect and kitura

@sarathy Same with Perfect and Kitura - it’s just a binary app that you can run wherever