Skip to content

Commit

Permalink
Rewrote and tested in Typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
donburgess committed Jan 29, 2017
1 parent cb7be46 commit 38cb2bb
Show file tree
Hide file tree
Showing 16 changed files with 735 additions and 220 deletions.
26 changes: 2 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,8 @@ pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
# Build Files
dist
12 changes: 12 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# VS Code #
.vscode

# Dev #
*.ts
!*.d.ts
*.spec.*
gulpfile.js
tslint.js
tsconfig.json
node_modules
example
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/example/example-server.js",
"cwd": "${workspaceRoot}",
"outFiles": [],
"sourceMaps": true
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858,
"outFiles": [],
"sourceMaps": true
}
]
}
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Your action function requires two parameters to be successful:

Message is what is being sent to the server and callback should be called with a return message for the requester.

Responses will be turned into an Object and have the response assigned to Object.msg which is then sent out as a buffer.
Responses are expected to be an Object and is then sent out as a buffer.

# Connecting To Server
```
Expand All @@ -23,24 +23,24 @@ function rpcAction(rpcMessage, callback) {
console.log(rpcMessage);
// Send Response To Requester
callback('Received');
callback({ resp: 'Success!' });
}
// Require Server Module
var RPC = require('rpc-server');
var Config = require('@db3dev/rabbitmq-rpc-server').Config,
Server = require('@db3dev/rabbitmq-rpc-server').Server;
// Configure Server to Connect to RabbitMQ Server
var config = RPC.Config({
var config = new Config({
username: 'user',
password: 'password',
host: 'example.com',
vhost: 'vhost',
queueName: 'rpc_api'
});
// Start Server
var server = RPC.server(config);
// Instantiate Server
var server = new Server(config);
// Attempt to connect to server
server.connect(rpcAction); // returns a promise
Expand Down
70 changes: 0 additions & 70 deletions config.js

This file was deleted.

40 changes: 40 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const gulp = require('gulp'),
ts = require('gulp-typescript'),
tslint = require('gulp-tslint'),
jasmine = require('gulp-jasmine'),
del = require('del'),
merge = require('merge2');

// pull in the project TypeScript config
const tsProject = ts.createProject('tsconfig.json');

gulp.task('clean', () => {
return del(['dist'])
});

gulp.task('transpile', () => {
const tsResult = tsProject.src()
.pipe(tsProject());

return merge([
tsResult.dts.pipe(gulp.dest('dist')),
tsResult.js.pipe(gulp.dest('dist'))
]);
});

gulp.task('lint', () => {
return gulp.src('./src/**/*.ts')
.pipe(tslint())
.pipe(tslint.report());
});

gulp.task('test', () => {
gulp.src('dist/*.spec.js')
.pipe(jasmine());
});

gulp.task('watch', ['lint', 'transpile', 'test'], () => {
gulp.watch('src/**/*.ts', ['lint', 'transpile']);
});

gulp.task('default', ['clean', 'lint', 'transpile']);
4 changes: 0 additions & 4 deletions index.js

This file was deleted.

27 changes: 24 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"name": "@db3dev/rabbitmq-rpc-server",
"version": "1.0.0",
"version": "2.0.0",
"description": "An AMQP/RabbitMQ RPC server controller",
"main": "index.js",
"scripts": {},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/db3dev/amqp-rpc-server-controller.git"
},
"scripts": {
"build": "gulp && npm test",
"test": "gulp test",
"example": "node ./example/start-example.js"
},
"keywords": [
"AMQP",
"RabbitMQ",
Expand All @@ -27,5 +32,21 @@
"homepage": "https://github.com/db3dev/amqp-rpc-server-controller#readme",
"dependencies": {
"amqplib": "^0.4.2"
},
"devDependencies": {
"@types/amqplib": "^0.5.1",
"@types/es6-promise": "0.0.32",
"@types/jasmine": "^2.5.41",
"@types/node": "^7.0.1",
"bluebird": "^3.4.7",
"del": "^2.2.2",
"gulp": "^3.9.1",
"gulp-jasmine": "^2.4.2",
"gulp-tslint": "^7.0.1",
"gulp-typescript": "^3.1.4",
"jasmine": "^2.5.3",
"merge2": "^1.0.3",
"tslint": "^4.4.2",
"typescript": "^2.0.0"
}
}
112 changes: 0 additions & 112 deletions server.js

This file was deleted.

Loading

0 comments on commit 38cb2bb

Please sign in to comment.