Skip to content

Commit c7e680e

Browse files
Merge pull request #197 from Automattic/plugins
middlewares architecture
2 parents 1debd67 + 74d10a6 commit c7e680e

38 files changed

+900
-1006
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
5.0.0 / 2017-05-21
2+
==================
3+
- Remove deprecated methods
4+
- Middleware architecture! See https://automattic.github.io/monk/docs/middlewares.html for more information
5+
16
4.1.0 / 2017-05-20
27
==================
38
- Update dev dependencies - Thanks @ratson(◕ᴥ◕)

LICENCE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Automattic
3+
Copyright (c) 2012 Guillermo Rauch <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TEST_TARGET ?= test/
66

77
lint:
88
echo " $(P) Linting"
9-
$(BIN_DIR)/eslint $(SRC_DIR) && $(BIN_DIR)/eslint $(TEST_TARGET)
9+
$(BIN_DIR)/eslint lib && $(BIN_DIR)/eslint test && $(BIN_DIR)/eslint middlewares
1010

1111
test: lint
1212
echo " $(P) Testing"

README.md

+24-30
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
# monk
1+
<h1 align="center">Monk</h1>
2+
3+
<div align="center">
4+
<img src="https://avatars2.githubusercontent.com/u/28830676?v=3&s=200" />
5+
</div>
6+
<br />
7+
<div align="center">
8+
<strong>A tiny layer that provides simple yet substantial usability
9+
improvements for MongoDB usage within Node.JS.</strong>
10+
</div>
11+
<br />
212

313
[![build status](https://secure.travis-ci.org/Automattic/monk.svg?branch=master)](https://secure.travis-ci.org/Automattic/monk)
414
[![codecov](https://codecov.io/gh/Automattic/monk/branch/master/graph/badge.svg)](https://codecov.io/gh/Automattic/monk)
515
[![Join the chat at https://gitter.im/Automattic/monk](https://badges.gitter.im/Automattic/monk.svg)](https://gitter.im/Automattic/monk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
616

7-
Monk is a tiny layer that provides simple yet substantial usability
8-
improvements for MongoDB usage within Node.JS.
9-
1017
*note*: monk 2.x drop the support for node < 0.12. If you are still using an earlier version, stick to monk 1.x
1118

1219
```js
@@ -28,41 +35,28 @@ db.close()
2835

2936
## Features
3037

31-
- Command buffering. You can start querying right away.
32-
- Promises built-in for all queries. Easy interoperability with modules.
38+
- Well-designed API signatures
3339
- Easy connections / configuration
34-
- Well-designed signatures
35-
- Improvements to the MongoDB APIs (eg: `findAndModify` supports the
36-
`update` signature style)
40+
- Command buffering. You can start querying right away
41+
- Promises built-in for all queries. Easy interoperability with modules
3742
- Auto-casting of `_id` in queries
3843
- Allows to set global options or collection-level options for queries. (eg:
3944
`safe` is `true` by default for all queries)
4045

41-
## How to use
46+
## Middlewares
4247

43-
[Documentation](https://Automattic.github.io/monk)
48+
Most of the Monk's features are implemented as [middleware](https://automattic.github.io/monk/docs/middlewares.html).
4449

45-
## License
50+
There are a bunch of third-parties middlewares that add even more functionalities to Monk:
51+
- [monk-middleware-wrap-non-dollar-update](https://github.com/monk-middlewares/monk-middleware-wrap-non-dollar-update)
52+
- [monk-middleware-debug](https://github.com/monk-middlewares/monk-middleware-debug)
4653

47-
(The MIT License)
54+
*Created an nice middleware? Send a PR to add to the list!*
4855

49-
Copyright (c) 2012 Guillermo Rauch &lt;[email protected]&gt;
56+
## How to use
5057

51-
Permission is hereby granted, free of charge, to any person obtaining
52-
a copy of this software and associated documentation files (the
53-
'Software'), to deal in the Software without restriction, including
54-
without limitation the rights to use, copy, modify, merge, publish,
55-
distribute, sublicense, and/or sell copies of the Software, and to
56-
permit persons to whom the Software is furnished to do so, subject to
57-
the following conditions:
58+
[Documentation](https://Automattic.github.io/monk)
5859

59-
The above copyright notice and this permission notice shall be
60-
included in all copies or substantial portions of the Software.
60+
## License
6161

62-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
63-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
64-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
65-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
66-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
67-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
68-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62+
MIT

SUMMARY.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
## Monk
22

3-
* [Read Me](/README.md)
3+
* [Introduction](/README.md)
44
* [Getting Started](/docs/GETTING_STARTED.md)
55

6+
## Guides
7+
* [Middlewares](/docs/middlewares.md)
8+
* [Debugging](/docs/Debugging.md)
9+
* [Writing a middleware](/docs/writing-middleware.md)
10+
611
## API Reference
712
* [Manager](/docs/manager/README.md)
813
* [close](/docs/manager/close.md)
914
* [create](/docs/manager/create.md)
1015
* [get](/docs/manager/get.md)
16+
* [addMiddleware](/docs/manager/addMiddleware.md)
1117
* [Collection](/docs/collection/README.md)
1218
* [aggregate](/docs/collection/aggregate.md)
1319
* [bulkWrite](/docs/collection/bulkWrite.md)
@@ -28,9 +34,6 @@
2834
* [update](/docs/collection/update.md)
2935
* [id](/docs/id.md)
3036

31-
## Guides
32-
* [Debugging](/docs/Debugging.md)
33-
3437
---
3538

3639
* [Change Log](/CHANGELOG.md)

book.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
"gitbook": ">=3.2.2",
33
"title": "Monk",
44
"description": "The wise MongoDB API",
5-
"plugins": ["prism", "-highlight", "github", "anker-enable"],
5+
"plugins": ["edit-link", "prism", "-highlight", "github", "anker-enable"],
66
"pluginsConfig": {
77
"github": {
88
"url": "https://github.com/Automattic/monk/"
9+
},
10+
"edit-link": {
11+
"base": "https://github.com/Automattic/monk/redux/tree/master",
12+
"label": "Edit This Page"
913
}
1014
}
1115
}

docs/Debugging.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
# Query debugging
1+
# Debugging
2+
3+
To get some information on what monk is doing, use the `monk-middleware-debug`:
4+
5+
```
6+
npm install --save monk-middleware-debug
7+
```
8+
9+
```js
10+
db.addMiddleware(require('monk-middleware-debug))
11+
```
212
313
* If you wish to see what queries `monk` passes to the driver, simply leverage
414
[debug](http://github.com/visionmedia/debug):
@@ -12,13 +22,13 @@
1222
```bash
1323
DEBUG="monk:*" npm start
1424
```
15-
25+
1626
* You can also see the output from the mongo driver using `debug`:
1727
1828
```bash
1929
DEBUG="mongo:*" npm start
2030
```
21-
31+
2232
There are several separated features available on this namespace:
2333
2434
* Db: The Db instance log statements
@@ -29,9 +39,9 @@
2939
* Pool: Connection Pool specific log statements
3040
* Connection: Singular connection specific log statements
3141
* Ping: Replicaset ping inquiry log statements
32-
42+
3343
To see the output of only one of those features:
34-
44+
3545
```bash
3646
DEBUG="mongo:Cursor" npm start // will only print the Cursor log statements
3747
```

docs/manager/addMiddleware.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# `manager.addMiddleware`
2+
3+
Add a middleware to the middlewares chain.
4+
5+
#### Arguments
6+
7+
1. `middleware` *(function)*: the middleware to add the the chain
8+
9+
#### Example
10+
11+
```js
12+
db.addMiddleware(require('monk-plugin-dereference'))
13+
```

0 commit comments

Comments
 (0)