{"id":16224830,"url":"https://github.com/helje5/microexpress","last_synced_at":"2025-03-19T12:30:49.688Z","repository":{"id":63911902,"uuid":"118810330","full_name":"helje5/MicroExpress","owner":"helje5","description":"A micro web server framework on top of the official Swift HTTP API","archived":false,"fork":false,"pushed_at":"2019-03-22T19:48:16.000Z","size":69,"stargazers_count":29,"open_issues_count":0,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T18:41:46.190Z","etag":null,"topics":["express","swift","swift-framework","swift-server"],"latest_commit_sha":null,"homepage":"http://www.alwaysrightinstitute.com/microexpress/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helje5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-24T19:16:24.000Z","updated_at":"2024-07-07T15:56:17.000Z","dependencies_parsed_at":"2023-01-14T13:15:59.500Z","dependency_job_id":null,"html_url":"https://github.com/helje5/MicroExpress","commit_stats":null,"previous_names":["alwaysrightinstitute/microexpress"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helje5%2FMicroExpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helje5%2FMicroExpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helje5%2FMicroExpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helje5%2FMicroExpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helje5","download_url":"https://codeload.github.com/helje5/MicroExpress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243989576,"owners_count":20379648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","swift","swift-framework","swift-server"],"created_at":"2024-10-10T12:25:49.430Z","updated_at":"2025-03-19T12:30:49.424Z","avatar_url":"https://github.com/helje5.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch2\u003eµExpress\n  \u003cimg src=\"http://zeezide.com/img/MicroExpressIcon1024.png\"\n       align=\"right\" width=\"100\" height=\"100\" /\u003e\n\u003c/h2\u003e\n\n![Swift 4](https://img.shields.io/badge/swift-4-blue.svg)\n![macOS](https://img.shields.io/badge/os-macOS-green.svg?style=flat)\n![tuxOS](https://img.shields.io/badge/os-tuxOS-green.svg?style=flat)\n![Travis](https://travis-ci.org/AlwaysRightInstitute/MicroExpress.svg?branch=master)\n\n\u003e **NOTE**:\n\u003e The repository containing the \n\u003e [asynchronous variant of MicroExpress](https://github.com/NozeIO/MicroExpress)\n\u003e now lives at [Noze.io](https://github.com/NozeIO).\n\u003e Images have been updated.\n\u003e This repository will eventually revert to the\n\u003e [synchronous HTTP API variant](https://github.com/AlwaysRightInstitute/MicroExpress/tree/branches/swift-server-http-api).\n\nA micro server framework on top of the Swift Server WG HTTP API.\n\n**Swift NIO**: The Swift NIO version moved over \n[MicroExpress/NIO](https://github.com/NozeIO/MicroExpress/).\nThis is probably what you are looking for :-)\n\n\nIt adds an Express like API on top of the \nlow level Swift Server WG HTTP API.\n```swift\nimport MicroExpress\n\nlet app = Express()\n\napp.get(\"/moo\") { req, res, next in\n  try res.send(\"Muhhh\")\n}\napp.get(\"/json\") { _, res, _ in\n  try res.json([ \"a\": 42, \"b\": 1337 ])\n}\napp.get(\"/\") { _, res, _ in\n  try res.send(\"Homepage\")\n}\n\napp.listen(1337)\n```\n\n\nThis package is part of the \n[Always Right Institute](http://www.alwaysrightinstitute.com)'s\nblog series about the \n[Swift Server Workgroup](https://swift.org/server-apis/)'s\noffical Swift\n[HTTP API](https://github.com/swift-server/http).\n\n- Blog series:\n  - Part 1 [Using the Swift Server API 0.1.0](http://www.alwaysrightinstitute.com/http-010/)\n  - Part 2 [µExpress](http://www.alwaysrightinstitute.com/microexpress/)\n  - Part 3 [µExpress/NIO](http://www.alwaysrightinstitute.com/microexpress-nio)\n\nPlease checkout [Part 3](http://www.alwaysrightinstitute.com/microexpress-nio)\nof our blog series to learn what this is about.\nThis is a tiny framework, for a more full featured, *synchronous*\nExpress-like API in Swift, have a look at \n[ExExpress](https://github.com/modswift/ExExpress)\n(as used in [ApacheExpress](http://apacheexpress.io)).\n[Noze.io](http://noze.io) comes w/ an *asynchronous* variant (but is using\nDispatch, not Swift NIO - stay tuned).\n\n\n## Using the Package\n\nMicro Hello World in 5 minutes (or in 30s using the \n[swift-xcode image](#swift-xcode) below):\n\n```shell\n$ mkdir MicroHelloWorld \u0026\u0026 cd MicroHelloWorld\n$ swift package init --type executable\n```\n\nUpdate `Package.swift` to include the dependency:\n```swift\n// swift-tools-version:4.0\nimport PackageDescription\n\nlet package = Package(\n  name: \"MicroHelloWorld\",\n  dependencies: [\n    .package(url: \"https://github.com/AlwaysRightInstitute/MicroExpress.git\", \n             .branch(\"branches/swift-nio-lib\"))\n  ],\n  targets: [\n    .target(name: \"MicroHelloWorld\",\n            dependencies: [ \"MicroExpress\" ])\n  ]\n)\n```\n\nChange the `main.swift` from `print(\"Hello World\")` into:\n```swift\nimport MicroExpress\n\nlet app = Express()\n\napp.get(\"/\") { req, res, next in\n  res.send(\"Hello World\")\n}\n\napp.listen(1337)\n```\n\n```shell\n$ swift build\n$ swift run\n```\n\nDone. Access via: [http://localhost:1337/](http://localhost:1337/)\n\n\n## Building the Package\n\n### Xcode\n\nChoose the easy way using the \n[swift-xcode](https://swiftxcode.github.io)\n[Swift NIO image](https://github.com/SwiftXcode/SwiftNIO_XcodeImage),\nor take the hard way and use `swift package generate-xcodeproj`.\n\n#### swift-xcode\n\n```shell\nbrew install swiftxcode/swiftxcode/swift-xcode-nio\nswift xcode link-templates # \u003c-- important!\n```\n\n1. Create new project (Command-Shift-N or File/New/Project ...)\n2. choose macOS / Server / Swift NIO template\n3. check desired options\n4. build and run, and then have fun!\n\n\u003cimg src=\"http://zeezide.com/img/microexpress-nio/01-new-project.jpg\" align=\"center\" /\u003e\n\n\u003cimg src=\"http://zeezide.com/img/microexpress-nio/02-new-project.jpg\" align=\"center\" /\u003e\n\n#### swift package generate-xcodeproj\n\nImportant: This creates a few schemes in the Xcode project. Make sure to\n           select the right one when building \u0026 running.\n\n```shell\n$ swift package generate-xcodeproj\nFetching ...\nCloning ...\nResolving ...\ngenerated: ./MicroExpress.xcodeproj\n\n$ open MicroExpress.xcodeproj\n```\n\n### macOS /Linux Command Line\n\n```shell\n$ swift build\nFetching ...\nCloning ...\nResolving ...\nCompile ...\nCompile Swift Module ...\nCompile Swift Module 'MicroExpress' (9 sources)\nLinking ./.build/x86_64-apple-macosx10.10/debug/MicroExpress\n```\n\n### Linux via macOS Docker\n\n```shell\n$ docker run --rm \\\n  -v \"${PWD}:/src\" \\\n  -v \"${PWD}/.docker.build:/src/.build\" \\\n  swift:4.0.3 \\\n  bash -c 'cd /src \u0026\u0026 swift build'\nUnable to find image 'swift:4.0.3' locally\n4.0.3: Pulling from library/swift\n8f7c85c2269a: Pull complete \n...\n9783e1c76d2b: Pull complete \nDigest: sha256:6978675b95f749b54eab57163c663d45b25c431c6d50cb5b2983062a55cea3c6\nStatus: Downloaded newer image for swift:4.0.3\nCompile ...\nCompile Swift Module ...\nCompile Swift Module 'MicroExpress' (9 sources)\nLinking ./.build/x86_64-unknown-linux/debug/MicroExpress\nFetching ...\nCloning ...\nResolving ...\n\n$ file .docker.build/x86_64-unknown-linux/debug/MicroExpress\n.docker.build/x86_64-unknown-linux/debug/MicroExpress: \n  ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked ...\n```\n\n\n### Links\n\n- [Swift NIO](https://github.com/apple/swift-nio)\n- [Noze.io](http://noze.io)\n- [ExExpress](https://github.com/modswift/ExExpress)\n- JavaScript Originals\n  - [Connect](https://github.com/senchalabs/connect)\n  - [Express.js](http://expressjs.com/en/starter/hello-world.html)\n- Swift Apache\n  - [mod_swift](http://mod-swift.org)\n  - [ApacheExpress](http://apacheexpress.io)\n- [Swiftmon/S](https://github.com/NozeIO/swiftmons)\n\n### Who\n\n**MicroExpress** is brought to you by\nthe\n[Always Right Institute](http://www.alwaysrightinstitute.com)\nand\n[ZeeZide](http://zeezide.de).\nWe like \n[feedback](https://twitter.com/ar_institute), \nGitHub stars, \ncool [contract work](http://zeezide.com/en/services/services.html),\npresumably any form of praise you can think of.\n\n\n### Want a Video Tutorial?\n\n\u003cimg src=\"http://zeezide.com/img/swift-nio-cows.gif\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelje5%2Fmicroexpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelje5%2Fmicroexpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelje5%2Fmicroexpress/lists"}