Nodes Vapor Template
A Vapor template for convenient and fast scaffolding 🏎
This template has everything ready to go. Just create a new project using Vapor toolbox.
vapor new MyApp --template=nodes-vapor/template
Getting started 🚀
The two keys in
crypto.json needs to be updated. You can use
openssl rand -base64 <length> to generate random strings. You can use length 10 for the key in the
hash object and you can use length 32 for the key in the
Before running your project, you need to make sure you have the following environment variables setup. For more information on how do this, have a look at our guide here.
$PROJECT_NAME: Name of your project.
$PROJECT_URL: Url for your project - there should most likely be one value per environment.
$BUGSNAG_KEY: API key for Bugsnag.
$DATABASE_HOSTNAME: Hostname for MySQL (this will fallback to
$DATABASE_USER: User for MySQL (this will fallback to
$DATABASE_PASSWORD: Password for MySQL (this will fallback to ``, which is the empty string).
$DATABASE_DB: Database name for project in MySQL (this will fallback to
$REDIS_HOSTNAME: Hostname for Redis (this will fallback to
$REDIS_DATABASE: Redis database.
Environment variables related to MySQL and Redis will be set automatically if you use e.g. Vapor Cloud. All other variables needs to be set manually, e.g. through the CLI tool. For more information, have a look at the official Vapor Cloud docs.
Project layout 🗂
The project is split up into two modules:
Run contains the
main.swift and is used for building the main executable.
MyProject-Package is where all of your server's code will be and is the module used for tests. When you add a source file to your project please make sure it's a member of the
Xcode project 🔨
Vapor toolbox makes it simple to generate a project for Xcode.
vapor xcode -y
Starting your server 🏁
In Xcode, select the
Run scheme if you want to startup your server.
Testing your code ⏱
For testing, make sure to have the
MyProject-Package scheme selected. Then, you can use
⌘U like usual.
This package is open-sourced software licensed under the MIT license