mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
29 lines
579 B
JavaScript
29 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);
|
|
|
|
}
|
|
}
|