Giter Club home page Giter Club logo

macro's Introduction

Macro

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.

Macro is a more capable variant of µExpress. The goal is still to keep a small core, but add some Noze.io modules and concepts.

Eventually it might evolve into Noze.io v2 (once backpressure enabled streams are fully working).

The companion MacroExpress package adds Express.js-like middleware processing and functions, as well as templates. MacroLambda has the bits to directly deploy Macro applications on AWS Lambda.

Streams

Checkout Noze.io for people who don't know Node, most things apply to Macro as well.

What does it look like?

The Macro Examples package contains a few examples which all can run straight from the source as swift-sh scripts.

The most basic HTTP server:

#!/usr/bin/swift sh
import Macro // @Macro-swift ~> 0.8.0

http
  .createServer { req, res in
    res.writeHead(200, [ "Content-Type": "text/html" ])
    res.write("<h1>Hello Client: \(req.url)</h1>")
    res.end()
  }
  .listen(1337)

Macro also provides additional Node-like modules, such as:

  • fs
  • path
  • jsonfile
  • JSON
  • basicAuth
  • querystring

Environment Variables

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

Async/Await

This intentionally doesn't support async/await yet as proper streaming would require custom executors. Which are not yet available.

Links

Who

Macro 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!

macro's People

Contributors

helje5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jingyuhai520

macro's Issues

Add support for async/await (pending custom executors)

It would be really nice to support async/await in Swift 5.5, but alas, it requires thread hopping towards SwiftNIO, which makes it kinda useless.

So let's wait until Swift supports custom executors (and potentially SwiftNIO 3), which would presumably allow integration w/ SwiftNIO.

Apply loglevels in the environment

When switching to the "official" Logging package, we lost the ability to easily set loglevels? Like export LOGLEVEL=trace.

We should fix that and have Macro configure the logging system if such env vars are found.

Boilerplate:

LoggingSystem.bootstrap { label in
  var handler = StreamLogHandler.standardOutput(label: label)
  handler.logLevel = .trace
  return handler
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.