g2-ops-config
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -27,2 +27,18 @@ 'use strict'; | ||
/** | ||
* Date util for logging | ||
*/ | ||
var getDate = function getDate() { | ||
var d = new Date(); | ||
var YYYY = d.getFullYear(); | ||
var MM = ('' + d.getMonth()).padStart(2, '0'); | ||
var DD = ('' + d.getDate()).padStart(2, '0'); | ||
var hh = d.getHours(); | ||
var mm = d.getMinutes(); | ||
var ss = d.getSeconds(); | ||
var SSS = ('' + d.getMilliseconds()).padStart(2, '0'); | ||
return YYYY + '-' + MM + '-' + DD + ' ' + hh + ':' + mm + ':' + ss + '.' + SSS; | ||
}; | ||
/** | ||
* Is the config server params that the config server needs to respond. | ||
@@ -48,3 +64,4 @@ */ | ||
if (!configParams.application || !configParams.endpoint || !configParams.profiles) { | ||
throw new Error('process.env[application || endpoint || profiles] are not present'); | ||
console.log(getDate() + ' [ERROR] process.env[application || endpoint || profiles] are not present, config url will be empty'); | ||
return ''; | ||
} | ||
@@ -100,6 +117,6 @@ return 'http://' + configParams.auth.user + ':' + configParams.auth.pass + '@' + configParams.endpoint + '/' + application + '/' + profile; | ||
return Promise.all(yamlPromises).then(function (data) { | ||
console.log(JSON.stringify(data)); | ||
console.log(getDate() + ' [INFO] ' + JSON.stringify(data)); | ||
return transformYamlResponse(data, profiles); | ||
}).catch(function (err) { | ||
console.log(err); | ||
console.log(getDate() + ' [ERROR] ' + err); | ||
}); | ||
@@ -106,0 +123,0 @@ } |
{ | ||
"name": "g2-ops-config", | ||
"version": "0.0.25", | ||
"description": "To fetch and maintain cloud configs for difference projects", | ||
"version": "0.0.26", | ||
"description": "To fetch and maintain cloud configs for different projects", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -15,2 +15,18 @@ // @flow | ||
/** | ||
* Date util for logging | ||
*/ | ||
const getDate = () => { | ||
const d = new Date() | ||
const YYYY = d.getFullYear() | ||
const MM = `${d.getMonth()}`.padStart(2, '0') | ||
const DD = `${d.getDate()}`.padStart(2, '0') | ||
const hh = d.getHours() | ||
const mm = d.getMinutes() | ||
const ss = d.getSeconds() | ||
const SSS = `${d.getMilliseconds()}`.padStart(2, '0') | ||
return `${YYYY}-${MM}-${DD} ${hh}:${mm}:${ss}.${SSS}` | ||
} | ||
/** | ||
* Is the config server params that the config server needs to respond. | ||
@@ -20,3 +36,3 @@ */ | ||
application: process.env.SPRING_APPLICATION_NAME, | ||
endpoint: (process.env.CONFIGSERVER_NAME).replace(/http.*:\/\//g, ''), | ||
endpoint: process.env.CONFIGSERVER_NAME.replace(/http.*:\/\//g, ''), | ||
profiles: process.env.PROFILES.split(','), | ||
@@ -36,3 +52,6 @@ auth: { | ||
if (!configParams.application || !configParams.endpoint || !configParams.profiles) { | ||
throw new Error('process.env[application || endpoint || profiles] are not present') | ||
console.log( | ||
`${getDate()} [ERROR] process.env[application || endpoint || profiles] are not present, config url will be empty` | ||
) | ||
return '' | ||
} | ||
@@ -95,7 +114,7 @@ return `http://${configParams.auth.user}:${configParams.auth.pass}@${configParams.endpoint}/${application}/${profile}` | ||
.then((data) => { | ||
console.log(JSON.stringify(data)) | ||
console.log(`${getDate()} [INFO] ${JSON.stringify(data)}`) | ||
return transformYamlResponse(data, profiles) | ||
}) | ||
.catch((err) => { | ||
console.log(err) | ||
console.log(`${getDate()} [ERROR] ${err}`) | ||
}) | ||
@@ -102,0 +121,0 @@ } |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
291140
18
724
1