Mikey Mikey - 2 months ago 19x
Node.js Question

TypeError: acl.middleware() is not a function

I am trying to use ACL in my Node.js application.

Using acl module, I have the following code:

var express = require('express'),
logger = require('morgan'),
mongoose = require('mongoose'),
Acl = require('acl');

var app = express();

app.set('port', 8000);

mongoose.connect('mongodb://localhost:27017/test', function () {
console.log('Mongodb connection connected');

var acl = new Acl(new Acl.mongodbBackend(mongoose.connection.db, 'acl_'), logger());

roles: ['guest'],
allows: [
{ resources: '/test', permissions: 'get' }

console.log('acl.middleware is a ', typeof acl.middleware);

app.get('/test', acl.middlemare(), function (req, res) {


app.get('/unauthorized', acl.middlemare(), function (req, res) {


app.listen(app.get('port'), function () {
console.log('Express server listening on port %d', app.get('port'));

When I start the server, I get the following output:

Express server listening on port 8000
Mongodb connection connected
acl.middleware is a function
TypeError: acl.middleware() is not a function

Edit: After placing a logger, I am a given:
Error: Broke parameter contract

I cannot figure out what I am doing wrong.

I have looked at this related answer but still have no luck at getting it to work.

Is there something else that I am missing?


It's acl.middleware() not acl.middlemare() (w vs. m).