Open the project folder in terminal and sync up.
swift package update # update dependencies
swift package generate-xcodeproj # regenerate Xcode project
open *.xcodeproj # open Xcode
Before running the project, make sure MongoDB is installed on your machine and is running.
Assuming you have Docker for Mac installed and running, create a new MongoDB container with:
docker run --name example-mongo -p 27017:27017 mongo:latest
Or if you've done this once, start the existing container:
docker start example-mongo
brew update
brew install mongodb
Next, create the db folder for MongoDB to store the databases and check the permissions for the db folder:
mkdir -p /data/db
sudo chown -R `id -un` /data/db
Launch the MongoDB server:
mongod
Now, run the project on xcode.
The Postman (API Development Environment) is a neat tool for setting up and performing HTTP requests repeatably.
Create a POST request to the following URL:
http://localhost:8080/todos
And set the following two keys and values in the body:
key | value |
---|---|
id | 1 |
title | Hi! |
Note: If there are no key and values in the body of the post request, you will see the following error:
[ ERROR ] Abort.415: No 'Content-Type' header is present. ContentContainer.swift:320)
Create a GET request to the following URL:
http://localhost:8080/todos
You should see the created Todo from the POST
request.