All Projects → NozeIO → MicroExpress

NozeIO / MicroExpress

Licence: other
A micro web server framework on top of Swift NIO

Projects that are alternatives of or similar to MicroExpress

swift-nio-redis
A high performance Redis protocol (RESP) implementation for SwiftNIO
Stars: ✭ 27 (-78.4%)
Mutual labels:  swift-framework, asyncio, swift-server, swift-nio
swift-lambda-runtime
⚠️ Deprecated AWS Lambda Runtime - please use https://github.com/swift-server/swift-aws-lambda-runtime instead
Stars: ✭ 68 (-45.6%)
Mutual labels:  swift-server, swift-nio
redi-s
A performant Redis server implemented in SwiftNIO.
Stars: ✭ 69 (-44.8%)
Mutual labels:  swift-server, swift-nio
Swift-FFDB
a Object/Relational Mapping (ORM) support to iOS and MacOS .Since SwiftFFDB is build on top of FMDB.
Stars: ✭ 22 (-82.4%)
Mutual labels:  swift-server
Bytes
Swift Library for working with sequences of Bytes (aka [UInt8])
Stars: ✭ 35 (-72%)
Mutual labels:  swift-server
Shades
Easily add drop shadows, borders, and round corners to a UIView.
Stars: ✭ 14 (-88.8%)
Mutual labels:  swift-framework
extensions-kit
📦 Collection of Swift+Apple Frameworks extensions for speeding up software development [iOS & iPadOS].
Stars: ✭ 71 (-43.2%)
Mutual labels:  swift-framework
SwiftyJot
Use your finger to annotate images.
Stars: ✭ 14 (-88.8%)
Mutual labels:  swift-framework
MLLineChart
A simple Line Chart Lib
Stars: ✭ 28 (-77.6%)
Mutual labels:  swift-framework
apns
Helpful extensions and abstractions for using APNSwift
Stars: ✭ 75 (-40%)
Mutual labels:  swift-nio
FormToolbar
Simple, movable and powerful toolbar for UITextField and UITextView.
Stars: ✭ 85 (-32%)
Mutual labels:  swift-framework
pipeline
A Swift framework for working with Final Cut Pro X FCPXML files easily.
Stars: ✭ 47 (-62.4%)
Mutual labels:  swift-framework
EquationKit
Equations in Swift
Stars: ✭ 39 (-68.8%)
Mutual labels:  swift-framework
awesome-swift-nio
📖 A collaborative list of all things Swift NIO
Stars: ✭ 81 (-35.2%)
Mutual labels:  swift-nio
tinkoff-api
Python Tinkoff API client for asyncio and humans
Stars: ✭ 60 (-52%)
Mutual labels:  asyncio
aioScrapy
基于asyncio与aiohttp的异步协程爬虫框架 欢迎Star
Stars: ✭ 34 (-72.8%)
Mutual labels:  asyncio
sqlite-nio
Non-blocking wrapper for libsqlite3-dev using SwiftNIO
Stars: ✭ 33 (-73.6%)
Mutual labels:  swift-nio
YMFF
Feature management made easy.
Stars: ✭ 26 (-79.2%)
Mutual labels:  swift-framework
socketwrapper
Async/Sync networking library including UDP, TCP and TLS/TCP socket classes written in C++ 17.
Stars: ✭ 33 (-73.6%)
Mutual labels:  asyncio
Sequents
A simple continuous animation library for iOS UI.
Stars: ✭ 31 (-75.2%)
Mutual labels:  swift-framework

µExpress

Swift 4 Swift 5 macOS tuxOS

A micro server framework on top of SwiftNIO.

It adds an Express like API on top of the low level SwiftNIO API.

import MicroExpress

let app = Express()

app.get("/moo") { req, res, next in
  res.send("Muhhh")
}
app.get("/json") { _, res, _ in
  res.json([ "a": 42, "b": 1337 ])
}
app.get("/") { _, res, _ in
  res.send("Homepage")
}

app.listen(1337)

This package is part of the Always Right Institute's blog series about the Swift Server Workgroup's offical Swift HTTP API.

Please checkout Part 3 of our blog series to learn what this is about. This is a tiny framework, for a more full featured, synchronous Express-like API in Swift, have a look at ExExpress (as used in ApacheExpress). Noze.io comes w/ an asynchronous variant (but is using Dispatch, not SwiftNIO - stay tuned).

Note: There is Macro.swift, a more capable (and maintained) version of this.

Using the Package

Micro Hello World in 5 minutes (or in 30s using the swift-xcode image below):

$ mkdir MicroHelloWorld && cd MicroHelloWorld
$ swift package init --type executable

Update Package.swift to include the dependency:

// swift-tools-version:5.0
import PackageDescription

let package = Package(
  name: "MicroHelloWorld",
  dependencies: [
    .package(url: "https://github.com/NozeIO/MicroExpress.git", 
             from: "0.5.3")
  ],
  targets: [
    .target(name: "MicroHelloWorld",
            dependencies: [ "MicroExpress" ])
  ]
)

Change the main.swift from print("Hello World") into:

import MicroExpress

let app = Express()

app.get("/") { req, res, next in
  res.send("Hello World")
}

app.listen(1337)
$ swift build
$ swift run

Done. Access via: http://localhost:1337/

Building the Package

Xcode 11

Using Xcode 11 one can just open the Package.swift file.

macOS / Linux Command Line

$ swift build
Fetching https://github.com/apple/swift-nio.git
Fetching https://github.com/AlwaysRightInstitute/mustache.git
Completed resolution in 5.97s
Cloning https://github.com/AlwaysRightInstitute/mustache.git
Resolving https://github.com/AlwaysRightInstitute/mustache.git at 0.5.9
Cloning https://github.com/apple/swift-nio.git
Resolving https://github.com/apple/swift-nio.git at 2.12.0
[100/100] Merging module MicroExpress

Linux via macOS Docker

$ docker run --rm \
  -v "${PWD}:/src" \
  -v "${PWD}/.docker.build:/src/.build" \
  swift:5.1.3 \
  bash -c 'cd /src && swift build'
Unable to find image 'swift:5.1.3' locally
5.1.3: Pulling from library/swift
2746a4a261c9: Pull complete 
...
b5d1069a5aa4: Pull complete 
Digest: sha256:72d7e583452031ae88251263649fc56ea79f98f4147474080426fb5c1ff904aa
Status: Downloaded newer image for swift:5.1.3
Fetching https://github.com/apple/swift-nio.git
...
[99/99] Compiling MicroExpress Express.swift
[100/100] Merging module MicroExpress

Links

Who

MicroExpress is brought to you by the Helge Heß and 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!

Want a Video Tutorial?

(this one is still using SwiftXcode instead of the Xcode 11 SPM support)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].