mapple
v1.0.1
Published
A Connect middleware that matches request's url with a MongoDB document.
Downloads
40
Readme
Mapple
A Connect middleware that matches request's url with a MongoDB document. Also allows to PUT and DELETE pages (or documents).
Usage
Install with npm install mapple
. Then, where app
is a connect or express app :
mapple = require('mapple');
...
app.use(mapple(db, collectionName));
db
can be either a MongoDB URL, a Db object (created with the native drivermongodb
) or a Collection object.collectionName
is optionnal. It's the pages collection's name. It defaults topages
.
The middleware populates res.locals.document with the db document corresponding to the requested url (url is stored in the field route of the document).