Skip to content

Commit 5e1c123

Browse files
committed
Version 1.0.0
1 parent ae7d265 commit 5e1c123

File tree

3 files changed

+54
-23
lines changed

3 files changed

+54
-23
lines changed

README.md

+49-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# momi
22

3-
[![Greenkeeper badge](https://badges.greenkeeper.io/fluture-js/momi.svg)](https://greenkeeper.io/)
4-
53
**Mo**nadic **Mi**ddleware
64

75
> `npm install --save monastic fluture momi`
@@ -11,11 +9,13 @@ mechanism which encodes several effects:
119

1210
- **A build-up of state** through mutation of the `req` parameter
1311
- **An eventual response** through mutation of the `res` parameter
14-
- **Inversion of control** over the continuation by means of calling the `next` parameter
15-
- **Possible error branch** by means of calling the `next` parameter with a value
12+
- **Inversion of control** over the continuation by means of calling the
13+
`next` parameter
14+
- **Possible error branch** by means of calling the `next` parameter with
15+
a value
1616

17-
If we would want to encode all of these effects into a data-structure, we could
18-
use a `StateT(Future) -> StateT(Future)` structure:
17+
If we would want to encode all of these effects into a data-structure, we
18+
could use a `StateT(Future) -> StateT(Future)` structure:
1919

2020
- **A build-up of state** through the `State` monad
2121
- **An eventual response** through the right-sided value of `Future`
@@ -27,49 +27,80 @@ Middleware monad. This packages exposes the Middleware monad, comprised of
2727
`State` from [monastic][] and `Future` from [Fluture][]. Besides the
2828
monad itself, it also exposes some utility functions and structures for
2929
practically applying Middleware. One such utility is the `App` class,
30-
which allows composition of functions over Middleware to be written more like
31-
what you are used to from middleware as it comes with Connect, Express or Koa.
30+
which allows composition of functions over Middleware to be written more
31+
like what you are used to from middleware as it comes with Express or Koa.
3232

3333
## Usage
3434

35+
### Node
36+
37+
```console
38+
$ npm install --save momi
39+
```
40+
41+
On Node 12 and up, this module can be loaded directly with `import` or
42+
`require`. On Node versions below 12, `require` or the [esm][]-loader can
43+
be used.
44+
45+
### Deno and Modern Browsers
46+
47+
You can load the EcmaScript module from various content delivery networks:
48+
49+
- [Skypack](https://cdn.skypack.dev/[email protected])
50+
- [JSPM](https://jspm.dev/[email protected])
51+
- [jsDelivr](https://cdn.jsdelivr.net/npm/[email protected]/+esm)
52+
53+
### Old Browsers and Code Pens
54+
55+
There's a [UMD][] file included in the NPM package, also available via
56+
jsDelivr: https://cdn.jsdelivr.net/npm/[email protected]/dist/umd.js
57+
58+
This file adds `momi` to the global scope, or use CommonJS/AMD
59+
when available.
60+
61+
## Usage Example
62+
3563
```js
3664
import Z from 'sanctuary-type-classes';
3765
import qs from 'querystring';
66+
import http from 'http';
3867

3968
import {compose, constant} from 'monastic';
4069
import {go, mount, get, put} from 'momi';
4170

42-
const queryParseMiddleware = go(function*(next) {
71+
const queryParseMiddleware = go (function* (next) {
4372
const req = yield get;
44-
const query = qs.parse(req.url.split('?')[1]);
45-
yield put(Object.assign({query}, req));
73+
const query = qs.parse (req.url.split ('?')[1]);
74+
yield put (Object.assign ({query}, req));
4675
return yield next;
4776
});
4877

49-
const echoMiddleware = Z.map(req => ({
78+
const echoMiddleware = Z.map (req => ({
5079
status: 200,
5180
headers: {'X-Powered-By': 'momi'},
52-
body: req.query.echo
81+
body: req.query.echo,
5382
}), get);
5483

55-
const app = compose(
84+
const app = compose (
5685
queryParseMiddleware,
57-
constant(echoMiddleware)
86+
constant (echoMiddleware)
5887
);
5988

60-
mount(app, 3000);
89+
mount (http, app, 3000);
6190
```
6291

6392
## Examples
6493

6594
- **[Readme][example-1]** the code from [Usage](#usage), ready to run.
6695
- **[Express][example-2]** shows how to embed Momi within Express.
67-
- **[Bootstrap][example-3]** an extensive example showing application structure.
96+
- **[Bootstrap][example-3]** an example showing application structure.
6897
- **[Real World][example-4]** how momi is being used in real life.
6998

70-
[monastic]: https://github.com/wearereasonablepeople/monastic
99+
[monastic]: https://github.com/dicearr/monastic
71100
[Fluture]: https://github.com/fluture-js/Fluture
72101
[example-1]: https://github.com/fluture-js/momi/tree/master/examples/readme
73102
[example-2]: https://github.com/fluture-js/momi/tree/master/examples/express
74103
[example-3]: https://github.com/fluture-js/momi/tree/master/examples/bootstrap
75104
[example-4]: https://github.com/Avaq/node-server-skeleton/tree/master/src/bootstrap
105+
[esm]: https://github.com/standard-things/esm
106+
[UMD]: https://github.com/umdjs/umd

index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
//.
4747
//. You can load the EcmaScript module from various content delivery networks:
4848
//.
49-
//. - [Skypack](https://cdn.skypack.dev/momi@0.7.2)
50-
//. - [JSPM](https://jspm.dev/momi@0.7.2)
51-
//. - [jsDelivr](https://cdn.jsdelivr.net/npm/momi@0.7.2/+esm)
49+
//. - [Skypack](https://cdn.skypack.dev/momi@1.0.0)
50+
//. - [JSPM](https://jspm.dev/momi@1.0.0)
51+
//. - [jsDelivr](https://cdn.jsdelivr.net/npm/momi@1.0.0/+esm)
5252
//.
5353
//. ### Old Browsers and Code Pens
5454
//.
5555
//. There's a [UMD][] file included in the NPM package, also available via
56-
//. jsDelivr: https://cdn.jsdelivr.net/npm/momi@0.7.2/dist/umd.js
56+
//. jsDelivr: https://cdn.jsdelivr.net/npm/momi@1.0.0/dist/umd.js
5757
//.
5858
//. This file adds `momi` to the global scope, or use CommonJS/AMD
5959
//. when available.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "momi",
3-
"version": "0.7.2",
3+
"version": "1.0.0",
44
"description": "Monadic middleware",
55
"keywords": [
66
"fluture",

0 commit comments

Comments
 (0)