Angularjs is a browser-side mvc framework, and communicate server-side via restful-apis.
Normally, any server-side framework which support restful service can work with it, but I'm looking for one can work well with it.
In angularjs, we can use a $resource
to define a external resource, which has some operations. The code is like:
var User = $resource('/users/:id', {}, {
get: { method: 'GET'},
create: { method: 'POST'},
delete: { method: 'DELETE'},
resetPassword: { method: 'PUT', params: { reset: passord } }
});
var user = User.get({id: '123'});
user.delete();
You can see, the structure of the code is one uri with many operations.
I'm new to server-side js, and just looked a little about express. I feel it's not fit angularjs very well.
You can see the demo:
app.get('/', function(req, res){
res.send('Hello World');
});
app.get('/user/:id', function(req, res){
res.send('User: ' + id);
});
app.post('/user', function(req, res){
res.send(req.body);
});
It separate one uri by http-method
s.
I'm looking for a framework, that can let me write the code like:
app.route('/user/:id', {
get: get(req,res) { ... },
post: post(req, res) { ... },
resetPassword: put(req, res) {...}
});
The code is probably wrong, but I think you may know what I mean: It has similar structure as the angularjs' side.
Is there such frameworks I can try?
For use the MongoDB as database take a look in this:
For .NET solution you can check out ServiceStack
You should check out the author's client side router Page.js
If you know how to route an express app, this will be the easiest solution for you. It's also very lightweight