eureka-js-connection
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -6,5 +6,7 @@ const axios = require('axios') | ||
const defaultPort = process.env.EUREKA_PORT || 8761 | ||
const defaultEurekaUri = process.env.EUREKA_URI || `http://localhost` | ||
const defaultEurekaUrl = process.env.EUREKA_URL || `${defaultEurekaUri}:${defaultPort}` | ||
const getAllServices = (port = defaultPort) => | ||
axios.get(`http://localhost:${port}/`) | ||
const getAllServices = (url = defaultEurekaUrl) => | ||
axios.get(url) | ||
.then(prop('data')) | ||
@@ -11,0 +13,0 @@ .then(html => |
{ | ||
"name": "eureka-js-connection", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Example using netflix eureka", | ||
@@ -28,4 +28,5 @@ "main": "index.js", | ||
"finalhandler": "^1.1.2", | ||
"serve-static": "^1.14.1" | ||
"serve-static": "^1.14.1", | ||
"minimist": ">=1.2.2" | ||
} | ||
} |
@@ -5,6 +5,7 @@ # Eureka-js-connection | ||
# Usage | ||
## With url | ||
```js | ||
const getAllServices = require('eureka-js-connection') | ||
getAllServices() | ||
getAllServices('http://localhost:8080') | ||
.then(console.log) | ||
@@ -14,3 +15,7 @@ .catch(console.error) | ||
or with port | ||
# Via environment variables | ||
set en variables via cross-env | ||
EUREKA_PORT || 8761 | ||
EUREKA_URI || 'http://localhost' | ||
or EUREKA_URL || 'http://localhost:8080' | ||
@@ -20,5 +25,6 @@ ```js | ||
getAllServices(8761) | ||
getAllServices() | ||
.then(console.log) | ||
.catch(console.error) | ||
``` | ||
17
test.js
@@ -9,14 +9,17 @@ const test = require('ava') | ||
http | ||
.createServer((req, res) => | ||
serveStatic('./test')( | ||
req, res, finalHandler(req, res))) | ||
.listen(port) | ||
test('getAllServices()', async t => { | ||
const server = http | ||
.createServer((req, res) => | ||
serveStatic('./test')( | ||
req, res, finalHandler(req, res))) | ||
.listen(port) | ||
test('getAllServices', async t => { | ||
const services = await getAllServices(8761) | ||
const services = await getAllServices() | ||
const services2 = await getAllServices(`http://localhost:${port}`) | ||
console.log(services) | ||
t.deepEqual(services, services2) | ||
t.true(services[0].name.includes('a-bootiful-client')) | ||
t.true(services[0].url.includes('8080')) | ||
server.close() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39
28
43007
4
6
3