Swift as a Webserver on Linux – Blog written in Swift
- Spawn a Swift webserver on Linux
- Mustache template engine
- Add a simple design and work with static files
- PostgreSQL
- Create a page to Show an article
- Parse & Display Markdown
- Create a simple admin, for at least create and edit posts
- Dates, (display article creation)
- Users
- Comments / emoji reaction
- RSS feed
- Categories
- First install setup page
- gzip static content
- serve content/type to static file
- add global timeout to requests
- External Settings loading (e.g yml?)
- Quickly deploy in both local (OSX) and prod (Linux) -- Makefile + Dockerfile
- Make project works with both Swift Package Manager and Xcode
- Makefile to install dependencies on OSX/Linux
- Create a migration system for SQL
- Fully integrate docker-compose/Tutum for deployment (instead of external Postgres URL)
- Add an access/error log system and made it persist through a docker volume-container
- Create a cli to generate/scaffold project, models, routes, views, controllers
- Add unit testing
- Add front-end tools (Gulp + Bower at least)
- Add a Watcher which relaunch local server
- Initial README
- Get started document
- Contributing section
- Define the purpose of this repo (Blog engine vs. web framework)
Simply using the $.respond
method allow us to handle well errors.
For instance:
return $.respond("article list") {
let articles = try fetcher.findAll()
return try Response(status: .OK, body: ArticleViews.List.render(articles) >% root.render )
}
Will handle multiple common errors:
static func respond(identifier: String, @noescape closure: (Void) throws -> Response) -> Response {
$.log("Requested: \(identifier)")
do {
return try closure()
}
catch $.Error.Unwrap {
return Response(status: .BadRequest, body: "Unwrap" >% $.error)
}
catch FetcherError.SQL(message: let error) {
return Response(status: .BadRequest, body: error >% $.error)
}
catch FetcherError.NotFound {
return Response(status: .NotFound, body: "404" >% $.error)
}
catch let error as NSError {
return Response(status: .InternalServerError, body: error.localizedDescription >% $.error)
}
}
The project heavily depends on the (so nice) Zewo Stack, the best way to reach me is on their Slack.