Swiftpack.co - enums/Heze as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by enums.
enums/Heze 0.1.24
A light Swift server-side framework powered by Perfect 3.x.
⭐️ 12
🕓 2 weeks ago
.package(url: "https://github.com/enums/Heze.git", from: "0.1.24")


Heze is a light Swift server-side framework powered by Perfect 3.x.

Get started

Heze recommends MySQL 5.7.


  • Make sure you have mysql server 5.7 installed on your Mac.
  • Clone this repo.
  • Fill username and password field in config file at Workspace/HezeDemo/config.json.
  • Run swift package generate-xcodeproj to generate the Xcode project.
  • Edit path params in main.swift at HezeDemo.
  • RUN. Go to http://localhost:8080 to see how the demo looks.

View rendering

  • API: Use HezeHandler to process request and return a JSON object by using HezeResponse method.
  • Web: Use HezeView or HezeListView. HTML rendering uses Mustache tech which is powered by Perfect-Mustache

Routes need to be registered in AppDelegate. See the demo.


  • Request filter: Use HezeRequestFilter. Override requestFilter method to decide if the request can pass the filter.
  • Response filter: Use HezeResponseFilter.
  • Session: HezeSessionRequestFilter is a request filter to process session. Tokens are stored in MySQL by default.

Filter need to be registered in AppDelegate as a plugin.


Use HezeTimer.

Timer need to be registered in AppDelegate as a plugin.


Workspace contains:

  • config.json: Configration.
  • Public: Static resources.
  • Views: Web templates.


Context system allows you to create multiple servers in one target.

Every AppDelegate requires a context. HezeApp will storage some env vars in this context when it inits.

There are main context and meta context by default. You can create more context. See HezeContextBox.



Heze supports email.

Adding these config in config.json will enable the email client.

"mail": {
    "smtp": "smtp://xxx",
    "username": "noreply@xxx",
    "password": "",
    "name": "xxx-NoReply",
    "interval": 3.0,

It's powered by PerfectSMTP.

Need other database?

Look at class HezeDatabase. It's a abstract interface of database. Feel free to implement HezeDatabaseImpl yourself.

You may need to process Session yourself because HezeSessionRequestFilter is powered by PerfectSessionMySQL.


My website https://blog.yuusann.com is powered by Heze and SPiCa.

SPiCa is another framework which is used to create Vue app using Swift. Not opensource yet.


Feel free to contact me: i@yuusann.com


Stars: 12
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Fix multi-thread issues on socket client
2 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics