Priming the app for deployment

Before we can deploy our app, we need to set up a production config for our database. For our database, we will be using MongoDB as an add on service provided in Heroku for free. Enabling this service will pass the location of the MongoDB service as an environment variable to our app and we can use this to connect our app to the database. We will need to tell our app the location of this MongoDB server. Specifying it is as easy as creating a new folder called production under the Config folder and adding a mongo.json file inside of the production folder. To create this config, follow these steps:

  1. Open the Terminal and, inside the root level of your Vapor project, create a new folder called production inside ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.