var router = getRouter();
var app = getApp();
var User = require('../users/model');
var Url = require('./model');

/**
* Create a new shortened URL
* POST /urls
* Auth -> admin, staff
*/
router.post('/urls', User.auth('admin', 'staff'), function (req, res) {
  var errors = Url.validate(req.body);
  if (errors.length) return res.multiError(errors);
  var url = new Url(req.body);
  url.save(function (err, url) {
    if (err) return res.singleError('The URL must be unique');
    return res.json(url);
  });
});

/**
* Resolve a shortened URL
* GET /urls/go/:short
*/
router.get('/urls/go/:url', function (req, res) {
  Url
    .findOne({short: req.params.url})
    .exec(function (err, url) {
      if (err) return res.status(404).send();
      return res.redirect(url.full);
    });
});

/**
* Get a single URL
* GET /urls/:id
* Auth -> admin, staff
*/
router.get('/urls/:id', function (req, res) {
  Url
    .findById(req.params.id)
    .exec(function (err, url) {
      if (err) return res.internalError();
      return res.json(url);
    });
});

/**
* Get a list of URLs
* GET /urls
* Auth -> admin, staff
*/
router.get('/urls', User.auth('admin', 'staff'), function (req, res) {
  Url
    .find()
    .exec(function (err, urls) {
      if (err) return res.internalError();
      return res.json({urls: urls});
    });
});

/**
* Delete a URL
* DELETE /urls/:id
* Auth -> admin, staff
*/
router.delete('/urls/:id', User.auth('admin', 'staff'), function (req, res) {
  Url
    .findByIdAndRemove(req.params.id)
    .exec(function (err, url) {
      if (err) return res.internalError();
      return res.json({
        _id: url._id
      });
    });
});
@@ -27,21 +27,95 @@
 var 
-app = getApp(
+socket = rootRequire('app/helpers/socket');%0Avar io = socket('/urls', %5B'admin', 'staff'%5D
 );%0Av
@@ -544,16 +544,44 @@
 ique');%0A
+    io.emit('create', url);%0A
     retu
@@ -1693,32 +1693,31 @@
 ;%0A      
-return res.json(
+var response = 
 %7B%0A      
@@ -1738,16 +1738,83 @@
 %0A      %7D
+;%0A      io.emit('delete', response);%0A      return res.json(response
 );%0A    %7D

Add sockets to urls