Perfect is a web server and toolkit for developers using the the Swift programming language to build applications and other REST services. It lets developers build using only Swift to program both the client-facing and server-side of their projects. It’s the perfect backbone for cloud and mobile technologies. Developers can be more productive and efficient using Perfect to write less code and work in one fundamental language for all of their needs.
- Dockerfile (automatically used by Hasura for deployment)
FROM swift:3.1.0
RUN apt-get update
RUN apt-get install -y openssl libssl-dev uuid-dev
WORKDIR /swift-perfect
ADD swift-perfect /swift-perfect
RUN swift build
CMD .build/debug/swift-perfect
- Press the Clone & Deploy button and follow the instructions.
- The
hasura quickstart
command clones the project repository to your local computer, and also creates a free Hasura cluster, where the project will be hosted. - A git remote (called hasura) is created and initialized with your project directory.
- Run
git add .
,git commit
, andgit push hasura master
. - Run the below command to open your shiny new deployed reason app.
$ hasura microservice open api
- To make changes to the project, browse to
/microservices/api/swift-perfect
and edit the files according to your app. - Commit the changes, and perform
git push hasura master
to deploy the changes.
To test and make changes to this app locally, follow the below instructions.
- Open Terminal and
cd
into the project folder. - Run
swift build
to build the app. - Run
.build/debug/swift-perfect
to run it. - Make changes to the app, and see the changes in the browser
You can view the logs for your app by running the below command:
$ hasura microservice logs api
You can see the logs in your terminal, press CTRL + C
to stop logging.
- System dependencies, like changing the web-server can be made in the Dockerfile
- Swift deps can be managed by editing Package.swift.
If changes have been done to the dependencies, commit, and perform git push hasura master
to deploy the changes.
- If you have an existing perfect app which you would like to deploy, replace the code inside
/microservices/api/swift-perfect/
according to your app. - You may need to modify the Dockerfile if your build directory location has changed, but in most cases, it won't be required.
- Commit, and run
git push hasura master
to deploy your app.
Hasura comes with a few handy tools to make it easy to add backend features to your apps.
Every project comes with an Authentication kit, you can restrict the access to your app to specific user roles. It comes with a crisp UI for Signup and Login pages out of the box, which takes care of user registration and signing in.
Follow the Authorization docs to add Authentication kit to your app.
Hasura project is composed of a set of microservices. These include certain Hasura microservices like, postgres, nginx, data API, auth API and more but can also include your own microservices.
Hasura comes with set of Data APIs to access the Postgres database which comes bundled with every Hasura cluster. You can use packages like Alamofire
to make HTTP requests to the database.
Detailed docs of data APIs can be found here.