architect-restify

Expose restify server as architect plugin

architect-restify

expose restify server rest as architect plugin.

npm install --save architect-restify
{
  "packagePath": "architect-restify",
  port: process.env.PORT || 8080,
  host: process.env.IP || "0.0.0.0"
}

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 (errapp) {
    if (err) {
        throw err;
    }
    console.log("app ready");
});

Configure Architect with config.js :

module.exports = [{
    packagePath: "architect-restify",
    port: process.env.PORT || 8080,
    host: process.env.IP || "0.0.0.0"
}, './routes'];

Consume rest plugin in your ./routes/package.json :

{
  "name": "routes",
  "version": "0.0.1",
  "main": "index.js",
  "private": true,
 
  "plugin": {
    "consumes": ["rest"]
  }
}

Eventually register your routes in ./routes/index.js :

module.exports = function setup(optionsimportsregister) {
    var rest = imports.rest;
 
    // register routes  
    rest.get('/catalogue', function (reqresnext) {
        res.write("{'message':'hello, world'}");
    res.end();
    });
    
    register();
};