I want to overwrite the standard POST endpoint as part of a collection (via addCollection). This is my source code:
// Global API configuration
var Api = new Restivus({
prettyJson: true
});
Api.addCollection(Kits, {
authRequired: false,
excludedEndpoints: ['getAll', 'deleteAll', 'delete'],
endpoints: {
post: function () {
var name = this.bodyParams.name;
console.log ("Entity: " + JSON.stringify(name));
}
}
});
I can’t figure out why restivus (or meteor) isn’t using the code that I entered under this custom endpoint and is instead using the default built-in behavior of just INSERTing it into the collection?
I want to avoid having duplicate entries (over fields other than the _id), hence I want to first check with a findOne and only INSERT when I can’t find a record.
But the main problem is that for whatever reason I can’t figure out why it’s not executing my code
Did you ever get this working? I’m trying to figure out the same thing I think. I want to provide an API to a 3rd party service which will post information to my meteor app. I want to do some data validation and massage the data prior to creating the mongo db records. I have yet to find any sort of example that shows how to do this.
Really hoping @kahmali will read this and respond!
Thanks @kahmali, I did see that but I guess I’m such a noob it didn’t make a lot of sense to me. Also, I’m trying to figure out how to 1) create a token for my users to use and 2) how to make Restivus work with just the token and not other logins too. Your example seems to show both a token and a login?
Ah. What you’re looking for is custom auth. It’s pretty poorly documented, so I’m sorry about that. It’s hidden in the config options, when it deserves a section of its own explaining exactly how to work with it. I’m not exactly sure when I’ll have the time, but check out the links below and hopefully they’ll help: