Getting started with Vapor

image

A small project to understand the basic concepts of Vapor.

Run Command on Terminal

  1. To create a new project

$dev vapor new project_name -n
$dev vapor --help
  1. To create a new project with Fluent

$dev vapor new project_name
$dev Would you like to use Fluent? (--fluent/--no-fluent) <y/n> y
$dev fluent: Yes
$dev db: Postgres (Recommended)
$dev Would you like to use Leaf? (--leaf/--no-leaf)
$dev y/n> n
$dev leaf: No
  1. Install Brew (if you don’t have it)
refer to this link to install: https://brew.sh/
  1. To enable/disble services for Postgres

$dev brew services start postgresql
$dev brew services stop postgresql
$dev brew services restart postgresql
  1. Create a DB via Postgres assuming user name as todo_user and database name as todo_db

$dev createuser -P todo_user
$dev createdb -O todo_user todo_db
  1. Open the package assuming user name as todo_user and database name as todo_db

$dev cd project_name
$dev open Package.swift
  1. To check the active routes
$dev vapor run routes
  1. To migrate the database
$dev vapor run migrate

GitHub

View Github