This appears to be an implementation of the Rails Resource pattern. I like it. It saves a lot of boilerplate code at the beginning of a project. I just downloaded mean.io and replaced the articles controller with a one-liner. This is awesome!
var articles = require('../app/controllers/articles');
app.get('/articles', articles.all);
app.post('/articles', auth.requiresLogin, articles.create);
app.get('/articles/:articleId', articles.show);
app.put('/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.update);
app.del('/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.destroy);
//Finish with setting up the articleId param
app.param('articleId', articles.article);
and I added this:
var bridge = new (require('angular-bridge'))(app, {
urlPrefix : '/'
});
var mongoose = require('mongoose')
var Article = mongoose.model('Article')
bridge.addResource('articles', Article)
This API could be consumed by anything. There's nothing angular-specific about it. Perhaps the project should be renamed, unless you intend to do some tighter integration with Angular. Perhaps you already have plans for this?
One kind of integration I'd love to see would be to allow you to re-use Mongoose schemas in the browser to automatically generate your $resources. It would be nice if validations were available and introspectable in the browser so they could be integrated with angular's form validation.
This appears to be an implementation of the Rails Resource pattern. I like it. It saves a lot of boilerplate code at the beginning of a project. I just downloaded mean.io and replaced the articles controller with a one-liner. This is awesome!
Specifically, I edited mean/config/routes.js. I removed this:
and I added this:
This allowed me to throw away this file and the application still worked fine.
This API could be consumed by anything. There's nothing angular-specific about it. Perhaps the project should be renamed, unless you intend to do some tighter integration with Angular. Perhaps you already have plans for this?
One kind of integration I'd love to see would be to allow you to re-use Mongoose schemas in the browser to automatically generate your $resources. It would be nice if validations were available and introspectable in the browser so they could be integrated with angular's form validation.