Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

socketio-transceiver

0.0.1 • Public • Published

Transceiver

Transceiver adds real-time pubsub functionality to your Express.js app and optionally integrates with an Angular.js frontend. Based off of ideas (and code) from Sails.js, Transceiver lets you do things like this on your server:

app.get('/api/v1/users', function (req, res, next) {
  User.find().then(function(users) {
    res.json(users);
    if (res.io) {
      res.io.subscribe('User');
    }
  });
});

app.post('/api/v1/users', function (req, res, next) {
  User.create(req.query).then(function(user) {
    res.json(user);
    if (res.io) {
      res.io.publishCreate('User', user);
    }
  });
});

And things like this on your frontend (Angular in this case):

socket.get('/api/v1/users', function(users) {
    console.log("Users are:", users);
    $scope.$on("create:user", function(user) {
        console.log("New user created:", user);
    });
});

Tranceiver is currently considered an alpha library, meaning that it's not ready for embedding in production projects just yet.

install

npm i socketio-transceiver

Downloadsweekly downloads

1

version

0.0.1

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability