architect-socket-server

1.1.2 • Public • Published

architect-socket-server

architect socket server plugin

Installation

npm install --save architect-socket-server

Config Format

{
  "packagePath": "architect-socket-server",
  port: process.env.PORT || 1337,
  host: process.env.IP || "0.0.0.0"
}

Usage

Boot Architect :

var path = require('path');
var architect = require("architect");
 
var configPath = path.join(__dirname, "config.js");
var config = architect.loadConfig(configPath);
 
architect.createApp(config, function (err, app) {
    if (err) {
        throw err;
    }
    console.log("app ready");
});

Configure Architect with config.js :

module.exports = [{
    packagePath: "architect-socket-server",
    port: process.env.PORT || 1337,
    host: process.env.IP || "0.0.0.0"
}];

And in your index.js :

var path = require('path');
var architect = require('architect');
 
var configPath = path.join(__dirname, 'config.js');
var config = architect.loadConfig(configPath);
 
architect.createApp(config, function (err, app) {
    if (err) {
        throw err;
    }
    var socketserver = app.getService('socketserver');
    socketserver.on('connection', function (conn) {
        conn.write('hello');
    });
    console.log('app ready');
});

Options

  • port : tcp port to listent to
  • host : host to listen to
  • socket: unix socket to listen
  • interface : network interface name to listen to (must match os.networkInterfaces)
  • family : interface address family to listen to (with interface).

Package Sidebar

Install

npm i architect-socket-server

Weekly Downloads

2

Version

1.1.2

License

Apache-2.0

Unpacked Size

16.3 kB

Total Files

5

Last publish

Collaborators

  • echestier
  • vtricoire
  • jcreigno