/heroku-vapor-template

A fork of the Vapor3 API template preconfigured for Heroku

Primary LanguageSwift

Heroku API Template

Documentation Team Chat MIT License Swift 4.2

Using the template

  1. Clone the template

    # You can use either the Vapor Toolbox, or just git clone directly.
    
    $ vapor new YourApp --template=vzsg/heroku-vapor-template
    
    # Or:
    
    $ git clone https://github.com/vzsg/heroku-vapor-template YourApp
    $ cd YourApp
    $ rm -rf .git           # detach folder from template repo
    $ git init              # start new Git repo
    # Optional:  edit Package.swift - change "VaporApp" to whatever you like
  2. Create a Heroku application

    # Append --region=eu if you want to use the EU region
    $ heroku apps:create your-heroku-app-name
  3. Set up buildpack

    $ heroku buildpacks:set vapor/vapor
  4. Add a free database

    $ heroku addons:create heroku-postgresql:hobby-dev
  5. Commit and push

    $ git add .
    $ git commit -m "Initial commit"
    $ git push heroku master
    
  6. Test if it's working

    $ heroku open

Changes from the original api-template

  • PostgreSQL is used instead of SQLite, which is configured with the DATABASE_URL environment variable if provided. The configuration is compatible with both the free and paid plans of Heroku Postgres.
  • The provided Procfile ensures that all required command line parameters are passed to the app.
  • The HSTSMiddleware automatically redirects HTTP calls to their HTTPS equivalents.