Add a remote method user.new and call User.create() within it yourself.
I'm assuming that you're starting with the (lowercase) user.js and user.json model that is an extension of the built-in (uppercase) User model that ships with loopback.
In user.js, something like this:
module.exports = function(user) {
user.remoteMethod('new',
{
accepts: [
{arg: 'userInfo', type: 'object'}
],
returns: {
arg: 'success',
type: 'boolean'
}
}
);
user.new = function(userInfo, cb) {
user.create(userInfo, function(err, newUser) {
if(err) return cb(err, null);
return cb(null, true);
});
};
};
You can also modify the REST API http url path structure with an additional http property on the remote method specification. This is not strictly necessary since the method will by default take the name of the method. Would be cool if you could just modify this to override the behavior of the built-ins, but I haven't tested if that's possible. You can also enforce POSTing:
user.remoteMethod('new',
{
http: {path: '/new', verb: 'post'}, // <--
accepts: [
{arg: 'userInfo', type: 'object'}
],
returns: {
arg: 'success',
type: 'boolean'
}
}
);