Swiftpack.co - Package - enums/Heze
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

Heze

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

Get started

Heze recommends MySQL 5.7.

Install

  • 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.

Filter

  • 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.

Timer

Use HezeTimer.

Timer need to be registered in AppDelegate as a plugin.

Workspace

Workspace contains:

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

Context

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.

DO NOT TOUCH META CONTEXT.

Email

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.

Preview

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.

Question?

Feel free to contact me: i@yuusann.com

Github

link
Stars: 11

Related Packages

Releases

0.1.10 for swift_4_2_1 - 2021-01-11T15:24:24

Add autoreleasePool for request handler - 2021-01-11T15:23:08

0.1.9 for swift_4_2_1 - 2021-01-01T14:36:48

Fix mail subject issue - 2021-01-01T14:36:29

0.1.8 for swift_4_2_1 - 2020-12-23T16:37:19

Fix select - 2020-12-23T14:23:26

Change unarchive - 2020-12-19T08:56:10

Add unarchive - 2020-12-19T06:12:15

Fix compile issues on Swift 5 - 2020-11-13T05:44:48

Fix compile issues on Linux Swift 5 - 2020-11-12T18:11:47

Fix compile issues on Xcode 12 - 2020-10-28T15:26:00

Fix trap compile issue on Linux - 2020-06-30T08:02:50

First release - 2020-05-29T10:02:52