What services would one add to the api/services folder in sails.js

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'});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)