@@ -13,15 +13,18 @@ This repository contains examples for
1313
1414### Running Examples as Scripts
1515
16- Examples can be run as scripts using [ swift-sh] ( https://github.com/mxcl/swift-sh )
17- (can be installed using a simple ` brew install mxcl/made/swift-sh ` ).
16+ Single file examples can be either run as scripts using
17+ [ swift-sh] ( https://github.com/mxcl/swift-sh )
18+ (install using a simple ` brew install mxcl/made/swift-sh ` ),
19+ from within Xcode or via ` swift run ` .
1820
1921This also contains an example for deploying to AWS Lambda:
2022[ express-simple-lambda] ( Sources/express-simple-lambda/ ) .
2123
24+
2225## Examples
2326
24- ### httpd-helloworld
27+ ### [ httpd-helloworld] ( Sources/httpd-helloworld )
2528
2629Raw HTTP server w/o Express extras (middleware, templates).
2730
@@ -34,7 +37,7 @@ Single source file:
3437``` swift
3538#!/ usr/ bin/ swift sh
3639
37- import Macro // @Macro-swift ~> 0.0.12
40+ import Macro // @Macro-swift
3841
3942http.createServer { req, res in
4043 // log request
@@ -60,7 +63,7 @@ http.createServer { req, res in
6063}
6164```
6265
63- ### express-simple
66+ ### [ express-simple] ( Sources/express-simple )
6467
6568``` bash
6669$ Sources/express-simple/main.swift
@@ -75,8 +78,8 @@ Forms, cookies, JSON, sessions, templates and cows - you get it all!
7578``` swift
7679#!/ usr/ bin/ swift sh
7780
78- import MacroExpress // @Macro-swift ~> 0.0.4
79- import cows // @AlwaysRightInstitute ~> 1.0.0
81+ import MacroExpress // @Macro-swift
82+ import cows // @AlwaysRightInstitute
8083
8184let app = express ()
8285
@@ -148,7 +151,7 @@ Looks like this:
148151There is an AWS Lambda variant of this (with minor adjustments):
149152[ express-simple-lambda] ( Sources/express-simple-lambda/ ) .
150153
151- ### connect-simple
154+ ### [ connect-simple] ( Sources/connect-simple )
152155
153156Use the simpler ` connect ` module, instead of ` express ` .
154157Probably no need to do this in the real world, just use MacroExpress.
@@ -160,6 +163,15 @@ $ Sources/express-simple/main.swift
1601632020-06-03T14:58:59+0200 notice: Server listening on http://localhost:1337
161164```
162165
166+ ### [ todomvc] ( Sources/todomvc/ )
167+
168+ A MacroExpress implementation of a [ Todo-Backend] ( http://todobackend.com/ ) ,
169+ a simple JSON API to access and modify a list of todos.
170+
171+ ``` bash
172+ $ swift run todomvc
173+ 2020-06-03T14:58:59+0200 notice: Server listening on http://localhost:1337
174+ ```
163175
164176
165177## Who
0 commit comments