mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-23 22:27:34 -05:00
28 lines
579 B
JavaScript
28 lines
579 B
JavaScript
var Handlebars = require('handlebars')
|
|
var request = require('request')
|
|
|
|
module.exports.notify = function(metadata, config) {
|
|
|
|
if (config.notify && config.notify.content) {
|
|
|
|
var template = Handlebars.compile(config.notify.content)
|
|
var content = template( metadata )
|
|
|
|
var options = {
|
|
body: content
|
|
}
|
|
|
|
if ( config.notify.headers ) {
|
|
options.headers = config.notify.headers;
|
|
}
|
|
|
|
options.method = config.notify.method;
|
|
|
|
if(config.notify.endpoint) {
|
|
options.url = config.notify.endpoint
|
|
}
|
|
|
|
request(options);
|
|
|
|
}
|
|
}
|