npm.io
0.1.0 • Published 11 years ago

sails-hook-gravatar

Licence
MIT
Version
0.1.0
Deps
0
Vulns
0
Weekly
0

sails gravatar hook

why

I needed a simple plug-in to experiment around sailsjs extensions.

what

It decorates a given model with a new method "gravatar" that outputs a gravatar url.

By default, it will decorate User and search for an email property to perform the md5 hash. If you want to override those, you can create a config.gravatar object, having the following structure :

{
    model: 'ModelName',
    field: 'fieldName'
}

It will also create a custom route get /<ModelName>/:id/gravatar for your api, and responds a formatted message:

{
    url: 'GravatarUrl'
}

You can disable this by adding route: false to the configuration object.

how
npm install sails-hook-gravatar

that's it.

Keywords