Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remit

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remit - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

26

index.js
'use strict'
const amqp = require('amqp')
const debug = require('debug')('lacklen')
const debug = require('debug')('remit')
const uuid = require('node-uuid').v4

@@ -9,6 +9,6 @@ const os = require('os')

module.exports = function (opts) {
return new Lacklen(opts)
return new Remit(opts)
}
function Lacklen (opts) {
function Remit (opts) {
if (!opts) opts = {}

@@ -24,3 +24,3 @@

this._exchange = null
this._exchange_name = 'lacklen'
this._exchange_name = 'remit'
this._exchange_callbacks = []

@@ -39,3 +39,3 @@

Lacklen.prototype.res = function res (event, callback, context, options) {
Remit.prototype.res = function res (event, callback, context, options) {
debug('res')

@@ -87,3 +87,3 @@

Lacklen.prototype.req = function req (event, args, callback, options) {
Remit.prototype.req = function req (event, args, callback, options) {
debug('req')

@@ -156,3 +156,3 @@

Lacklen.prototype.emit = function emit (event, args, options) {
Remit.prototype.emit = function emit (event, args, options) {
debug('emit')

@@ -169,3 +169,3 @@

Lacklen.prototype.listen = function listen (event, callback, context, options) {
Remit.prototype.listen = function listen (event, callback, context, options) {
if (!this._service_name) {

@@ -187,3 +187,3 @@ console.log('MUST PROVIDE A SERVICE NAME IF LISTENING')

Lacklen.prototype.__connect = function __connect (callback) {
Remit.prototype.__connect = function __connect (callback) {
debug('__connect')

@@ -231,3 +231,3 @@

Lacklen.prototype.__assert_exchange = function __assert_exchange (callback) {
Remit.prototype.__assert_exchange = function __assert_exchange (callback) {
debug('__assert_exchange')

@@ -265,3 +265,3 @@

Lacklen.prototype.__assert_result_queue = function __assert_result_queue (callback) {
Remit.prototype.__assert_result_queue = function __assert_result_queue (callback) {
debug('__assert_result_queue')

@@ -311,3 +311,3 @@

Lacklen.prototype.__on_result = function __on_result (msg, headers, info) {
Remit.prototype.__on_result = function __on_result (msg, headers, info) {
debug('__on_result')

@@ -341,4 +341,4 @@

Lacklen.prototype.__generate_queue_name = function (type) {
Remit.prototype.__generate_queue_name = function (type) {
return os.hostname() + ':pid' + process.pid + ':' + type
}
{
"name": "remit",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

@@ -15,24 +15,3 @@ "main": "index.js",

"node-uuid": "^1.4.3"
},
"_id": "lacklen@1.0.3",
"_shasum": "297ddbcad920e96cd31e1c62321ed84650492d8f",
"_from": "lacklen@*",
"_npmVersion": "2.14.7",
"_nodeVersion": "4.2.1",
"_npmUser": {
"name": "jpwilliams",
"email": "jack@tagstr.co"
},
"dist": {
"shasum": "297ddbcad920e96cd31e1c62321ed84650492d8f",
"tarball": "http://registry.npmjs.org/lacklen/-/lacklen-1.0.3.tgz"
},
"maintainers": [
{
"name": "jpwilliams",
"email": "jack@tagstr.co"
}
],
"directories": {},
"_resolved": "https://registry.npmjs.org/lacklen/-/lacklen-1.0.3.tgz"
}
}

@@ -1,3 +0,3 @@

# What's Lacklen?
`lacklen` is intended to be a small set of functionality used to create simple microservices that don't need to be aware of one-another's existence.
# What's Remit?
`remit` is intended to be a small set of functionality used to create simple microservices that don't need to be aware of one-another's existence.

@@ -8,3 +8,3 @@ It uses _RabbitMQ_ at its core to manage service discovery-like behaviour without the need to explicitly connect one service to another.

To use `lacklen` you'll need:
To use `remit` you'll need:
* A _RabbitMQ_ server

@@ -16,5 +16,5 @@ * _Node v4.x.x_

Once your _RabbitMQ_ server's up and running, simply use `npm` to install `lacklen`!
Once your _RabbitMQ_ server's up and running, simply use `npm` to install `remit`!
```javascript
npm install lacklen
npm install remit
```

@@ -24,3 +24,3 @@

`lacklen` makes use of four simple commands: `req` (request), `res` (respond), `emit` and `listen`.
`remit` makes use of four simple commands: `req` (request), `res` (respond), `emit` and `listen`.

@@ -33,3 +33,3 @@ * `req` requests data from a defined endpoint which, in turn, is created using `res`

```javascript
const lacklen = require('lacklen')({
const remit = require('remit')({
name: 'my_service', // this is required for a service that has a listener

@@ -44,3 +44,3 @@ url: 'amqp://localhost'

// API
lacklen.req('add', {
remit.req('add', {
first: 2,

@@ -53,10 +53,10 @@ second: 7

// Server
lacklen.res('add', function (args, done) {
remit.res('add', function (args, done) {
done(null, (args.first + args.second))
lacklen.emit('something.happened', args)
remit.emit('something.happened', args)
})
// Listener 1
lacklen.listen('something.happened', function (args) {
remit.listen('something.happened', function (args) {
console.log(args)

@@ -66,3 +66,3 @@ })

// Listener 2
lacklen.listen('something.#', function (args) {
remit.listen('something.#', function (args) {
console.log('Something... did something...')

@@ -83,3 +83,3 @@ })

There are two methods for sending messages with `lacklen`: _request_ or _emit_.
There are two methods for sending messages with `remit`: _request_ or _emit_.

@@ -91,4 +91,4 @@ A _request_ implies that the requester wants a response back, whereas using an _emission_ means you wish to notify other services of an event without requiring their input.

```javascript
// Import lacklen and connect to our AMQP server
const lacklen = require('lacklen')()
// Import remit and connect to our AMQP server
const remit = require('remit')()

@@ -100,4 +100,4 @@ // Import whatever HTTP API creator we want

api.get('/login', function (req, res) {
// Send a request via lacklen to the 'user.login' endpoint
lacklen.req('user.login', {
// Send a request via remit to the 'user.login' endpoint
remit.req('user.login', {
username: req.username,

@@ -118,7 +118,7 @@ password: req.password

```javascript
// Import lacklen and connect to our AMQP server
const lacklen = require('lacklen')()
// Import remit and connect to our AMQP server
const remit = require('remit')()
// Respond to 'user.login' events
lacklen.res('user.login', function (args, done) {
remit.res('user.login', function (args, done) {
// If it's not Mr. Bean, send back an error!

@@ -137,3 +137,3 @@ if (args.username !== 'Mr. Bean') return done('You\'re not Mr. Bean!')

Let's now say that we want a service to listen out for if it's a user's birthday and send them an email if they've logged in on that day! With most other systems, this would require adding business logic to our login service to explicitly call some `birthday` service and check, but not with `lacklen`.
Let's now say that we want a service to listen out for if it's a user's birthday and send them an email if they've logged in on that day! With most other systems, this would require adding business logic to our login service to explicitly call some `birthday` service and check, but not with `remit`.

@@ -144,3 +144,3 @@ At the end of our `authentication` service, let's add an emission of `user.login.success`.

// Respond to 'user.login' events
lacklen.res('user.login', function (args, done) {
remit.res('user.login', function (args, done) {
// If it's not Mr. Bean, send back an error!

@@ -158,3 +158,3 @@ if (args.username !== 'Mr. Bean') return done('You\'re not Mr. Bean!')

// After we've logged the user in, let's emit that everything went well!
lacklen.emit('user.login.success', { user })
remit.emit('user.login.success', { user })
})

@@ -168,3 +168,3 @@ ```

```javascript
const lacklen = require('lacklen')({
const remit = require('remit')({
name: 'birthday'

@@ -175,3 +175,3 @@ })

lacklen.listen('user.login.success', function (args) {
remit.listen('user.login.success', function (args) {
let today = '14/06/1961'

@@ -192,3 +192,3 @@

```javascript
const lacklen = require('lacklen')({
const remit = require('remit')({
name: 'logger'

@@ -199,3 +199,3 @@ })

lacklen.listen('user.#', function (args) {
remit.listen('user.#', function (args) {
user_action_counter++

@@ -207,3 +207,3 @@ })

`lacklen`'s in its very early stages. Basic use is working well, but here are some features I'm looking at implementing to make things a bit more diverse.
`remit`'s in its very early stages. Basic use is working well, but here are some features I'm looking at implementing to make things a bit more diverse.

@@ -210,0 +210,0 @@ * Ability to specify exchange per connection, endpoint or event

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc