I have a question consisting of two parts:
- What are the types of services one would add to the api/services folder in a sails.js app.
- How would one 'wire' those services to the rest of the application.
Thanks,
TM
I have a question consisting of two parts:
Thanks,
TM
a service would be in my opinion, a piece of logic that you need in multiple locations of your app. for example an email service. the following is taken directly from the sails-wiki github page.
// EmailService.js - in api/services
exports.sendInviteEmail = function(options) {
var opts = {"type":"messages","call":"send","message":
{
"subject": "YourIn!",
"from_email": "info@balderdash.co",
"from_name": "AmazingStartupApp",
"to":[
{"email": options.email, "name": options.name}
],
"text": "Dear "+options.name+",\nYou're in the Beta! Click <insert link> to verify your account"
}
};
myEmailSendingLibrary.send(opts);
};
The wiring is done by sails itself:
// Somewhere in a conroller
EmailService.sendInviteEmail({email: 'test@test.com', name: 'test'});