How to use union - 10 common examples

To help you get started, we’ve selected a few union examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opsmezzo / quill / lib / quill / composer / remote.js View on Github external
exports.publish = function (system) {
  var tarball = new BufferedStream();

  //
  // Helper function which pipes `tarball` to the `quill.systems` client.
  // If tarball is a string, then a filestream will be created.
  //
  function uploadTarball(err) {
    if (err) {
      return tarball.emit('error', err);
    }

    tarball.emit('upload:start');
    tarball.pipe(quill.systems.upload(system.name, system.version, function (err) {
      return err
        ? tarball.emit('error', err)
        : tarball.emit('upload:end');
    }));
github hubbleio / hubble.io / server / index.js View on Github external
file.serve(req, res);
          }
        });
      };
    } else {
      return function(req, res{
        file.serve(req, res);
      };
    }
  }());

  //
  // stup a server and when there is a request, dispatch the
  // route that was requestd in the request object.
  //
  var server = union.createServer({
    before: [
      require('./middleware/favicon')(__dirname + '/../public/favicon.png'),
      require('flatware-cookie-parser')(),
      require('flatware-session')('sid', store),
      function (req, res) {
        req.url = req.url.replace(/%25/g, '%').replace(/%20/g, ' ');
        var found = router.dispatch(req, res);
        if (! found) {
          file(req, res);
        }
      }
    ]
  });


  server.on('close', function() {
github jfhbrook / node-ecstatic / test / union-error.js View on Github external
test('union', function (t) {
  var filenames = Object.keys(cases);
  var port = Math.floor(Math.random() * ((1<<16) - 1e4) + 1e4);

  var server = union.createServer({
    before: [
      ecstatic({
        root: root,
        gzip: true,
        baseDir: baseDir,
        autoIndex: true,
        showDir: true,
        handleError: false
      })
    ]
  });

  server.listen(port, function () {
    var pending = filenames.length;
    filenames.forEach(function (file) {
      var uri = 'http://localhost:' + port + path.join('/', baseDir, file),
github openruko / logplex / logplex / webserver.js View on Github external
self.start = function() {
    console.log('Logplex web server listening on port ' + options.port);
    var router = new director.http.Router();
    self.webServer = union.createServer({
      before: [
        function (req, res) {
          var found = router.dispatch(req, res);
          if (!found) {
            res.emit('next');
          }
        }
      ]
    });
    setupRoutes(router);
    self.webServer.listen(options.port);
  };
github twilson63 / node-cloudq / lib / web / node_modules / ecstatic / example / union.js View on Github external
var union = require('union');
var ecstatic = require('../');

union.createServer({
  before: [
    ecstatic(__dirname + '/public')
  ]
}).listen(8080);

console.log('Listening on :8080');
github eclipsesource / tabris-js / snippets / bin / server.js View on Github external
fail('Snippet does not exist.');
}

let externalAddresses = getExternalAddresses();
if (!externalAddresses.length) {
  fail('No remotely accessible network interfaces.');
}

let servePackageJson = (req, res, next) => {
  if (req.url === '/package.json') {
    return res.end(JSON.stringify({main: fileName}));
  }
  next();
};

let server = union.createServer({
  before: [servePackageJson, ecstatic({root: path.join(__dirname, '..')})]
});

server.listen(PORT, () => {
  let port = server.address().port;
  console.log(
    colors.yellow(`Server started for ${colors.red.bold(fileName)}.\nPoint your Tabris.js client to:`)
  );
  externalAddresses.forEach(
    iface => console.log(colors.green('  http://' + iface.address + ':' + port.toString()))
  );
});

function getExternalAddresses() {
  let interfaces = os.networkInterfaces();
  return Object.keys(interfaces)
github jfhbrook / node-ecstatic / example / union.js View on Github external
var union = require('union');
var ecstatic = require('../');

union.createServer({
  before: [
    ecstatic(__dirname + '/public')
  ]
}).listen(8080);

console.log('Listening on :8080');
github natesilva / node-docserver / examples / serveUnion.js View on Github external
(new Date()).toUTCString(),
    req.method,
    req.url
  ];

  var end = res.end;
  res.end = function() {
    message.push(res.statusCode);
    console.log(message.join(' - '));
    end.apply(res, arguments);
  };

  next();
};

var server = union.createServer({
  before: [
    logger,
    docserver({
      url: '/',
      dir: dir,
      headers: {'X-Powered-By': 'Narwhals'}
    })

  ]
}).listen(port);

console.log(docserver.version + ' serving ' + dir + ' on port ' + port +
  ' (with Union)');
github polkadot-js / api / packages / api-contract / src / MetaRegistry.ts View on Github external
function detectedType ({ def, id }: MetaType): MetaTypeInfo {
  assert(!(def as MetaTypeDefUnion)['union.fields'], 'Invalid union type definition found');

  const lookup = def === 'builtin'
    ? builtinMap.find(([test]): boolean => test(id))
    : typeMap.find(([test]): boolean => !!(def as any)[test]);

  return lookup
    ? lookup[1]
    : MetaTypeInfo.Null;
}
github LabsRS-Dev / AiEXifCool / server / server.js View on Github external
before: before,
    headers: this.headers,
    onError: function (err, req, res) {
      if (options.logFn) {
        options.logFn(req, res, err)
      }

      res.end()
    }
  }

  if (options.https) {
    serverOptions.https = options.https
  }

  this.server = nm_union.createServer(serverOptions)
}

union

A hybrid buffered / streaming middleware kernel backwards compatible with connect.

MIT
Latest version published 10 months ago

Package Health Score

77 / 100
Full package analysis