1.2.2 • Published 6 years ago

diet-connect v1.2.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

diet-connect

Compatibility layer for using Connect/Express middleware in diet.js apps

Use your favorite Express middleware out of the box

const compatible = require('diet-connect')
const logger = require('morgan')
const serve = require('express-static')
...
app.header(compatible(logger('dev')))
app.footer(compatible(serve(app.path + 'static')))

Proxies any assignment to req object by middleware to the signal object ($). For example, using express session usually adds .session to req; here it's attached to $

const session = require('express-session')
app.header(compatible(session(options)))

app.get('/counter', function ($) {
	$.session.views = $.session.views || 0
	$.session.views++
	$.end('you have viewed this page ' + $.session.views + ' times')
})
// refresh the page to see the counter go up

Examples

Examples

Known Incompatible Modules

  • body-parser Diet is inherently incompatible with Express' body parser, as Diet already does body parsing

Contact

Bug reports, feature requests, and questions are all welcome: open a GitHub issue and I'll get back to you.

This is especially true if a certain piece of middleware doesn't work. Please open an issue and I'll see what we need to do to get compatibility.

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago