Swiftpack.co - Macro-swift/MacroApp as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Macro-swift.
Macro-swift/MacroApp 0.6.0
A SwiftUI-like, declarative way to setup MacroExpress Endpoints
⭐️ 30
🕓 1 year ago
iOS macOS
.package(url: "https://github.com/Macro-swift/MacroApp.git", from: "0.6.0")

MacroApp

MacroApp layers on top of MacroExpress to provide a SwiftUI like, declarative setup of endpoints.

It is a little more opinionated than MacroExpress.

MacroExpress is a small, unopinionated "don't get into my way" / "I don't wanna wait" asynchronous web framework for Swift. With a strong focus on replicating the Node APIs in Swift. But in a typesafe, and fast way.

MacroApp is just syntactic sugar (using Swift function builders) on top of MacroExpress. The configuration is evaluated into a regular MacroExpress based app (with routes and middleware).

Example

MacroApp:

@main
struct HelloWorld: App {
  
  var body: some Endpoints {
    Use(logger("dev"), bodyParser.urlencoded())
          
    Route("/admin") {
      Get("/view") { req, res, _ in res.render("admin-index.html") }
      Render("help", template: "help")
    }
      
    Get { req, res, next in
      res.render("index.html")
    }
  }
}

Instead of this traditional route setup (as in MacroExpress):

let app = express()

app.use(logger("dev"), bodyParser.urlencoded())

app.route("/admin")
   .get("/view") { req, res, _ in res.render("admin-index.html") }

app.get("/") { req, res, _ in res.render("index.html") }

app.listen(1337) {
    console.log("Server listening on http://localhost:1337")
}

Environment Variables

  • macro.core.numthreads
  • macro.core.iothreads
  • macro.core.retain.debug
  • macro.concat.maxsize
  • macro.streams.debug.rc
  • macro.router.debug
  • macro.router.matcher.debug

Links

Who

MacroExpress is brought to you by Helge Heß / ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.

There is a #microexpress channel on the Noze.io Slack. Feel free to join!

GitHub

link
Stars: 30
Last commit: 11 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

TheLatest
1 year ago

Updated to use the latest SwiftNIO. This implies that Swift 5.5.2+ is now required.

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