-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"plugins": [ | ||
"transform-es2015-spread", | ||
"transform-es2015-destructuring", | ||
"transform-strict-mode", | ||
"transform-es2015-parameters", | ||
"transform-es2015-shorthand-properties", | ||
"transform-object-rest-spread", | ||
"transform-class-properties" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "airbnb/base", | ||
"parser": "babel-eslint", | ||
"rules": { | ||
"prefer-arrow-callback": 0, | ||
"max-len": [2, 150] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env node | ||
|
||
try { | ||
require('babel-register'); | ||
require('../src/index.js'); | ||
} catch (e) { | ||
require('../lib/index.js'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "ms-cli", | ||
"version": "1.0.0", | ||
"description": "cli to access microservices over amqp through command line", | ||
"main": "./lib/index.js", | ||
"bin": { | ||
"ms-cli": "./bin/ms-cli.js" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/makeomatic/ms-cli.git" | ||
}, | ||
"keywords": [ | ||
"microservice", | ||
"cli" | ||
], | ||
"author": "Vitaly Aminev <v@makeomatic.ru>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/makeomatic/ms-cli/issues" | ||
}, | ||
"homepage": "https://github.com/makeomatic/ms-cli#readme", | ||
"dependencies": { | ||
"bluebird": "^3.2.1", | ||
"bunyan": "^1.5.1", | ||
"ms-amqp-transport": "^1.3.0", | ||
"yargs": "^3.32.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.4.5", | ||
"babel-register": "^6.4.3", | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-preset-stage-0": "^6.3.13", | ||
"eslint": "^1.10.3", | ||
"eslint-config-airbnb": "^4.0.0", | ||
"babel-eslint": "^5.0.0-beta9" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const Promise = require('bluebird'); | ||
const getTransport = require('./transport.js'); | ||
const bunyan = require('bunyan'); | ||
const log = bunyan.createLogger({ name: 'ms-cli' }); | ||
|
||
const yargs = require('yargs') | ||
.usage('Usage: $0 --q.offset=0 --q.limit=10 -p payments.transactions.common -h rabbitmq -p 5672') | ||
.alias('p', 'port') | ||
.describe('p', 'rabbitmq port') | ||
.default('p', 5672) | ||
.alias('h', 'host') | ||
.describe('h', 'rabbitmq host') | ||
.default('h', 'localhost') | ||
.alias('r', 'route') | ||
.describe('r', 'rabbitmq routing key') | ||
.demand('r') | ||
.describe('q', 'query object') | ||
.default('q', {}) | ||
.alias('t', 'timeout') | ||
.describe('t', 'request timeout') | ||
.default('t', 15000); | ||
|
||
process.nextTick(() => { | ||
const argv = yargs.argv; | ||
|
||
// issue command | ||
Promise.using(getTransport(argv.host, argv.port), amqp => ( | ||
amqp.publishAndWait(argv.route, argv.q, { timeout: argv.timeout }).then(response => { | ||
log.info(response); | ||
}) | ||
)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const Promise = require('bluebird'); | ||
const AMQPTransport = require('ms-amqp-transport'); | ||
|
||
module.exports = function disposer(host, port) { | ||
return AMQPTransport | ||
.connect({ connection: { host, port } }) | ||
.disposer(amqp => { | ||
return amqp.close(); | ||
}); | ||
}; |