Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bimedia-fr/architect-restify
expose restify server as architect plugin
https://github.com/bimedia-fr/architect-restify
Last synced: 2 months ago
JSON representation
expose restify server as architect plugin
- Host: GitHub
- URL: https://github.com/bimedia-fr/architect-restify
- Owner: bimedia-fr
- License: apache-2.0
- Created: 2014-03-04T22:01:04.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-04-03T09:50:05.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T15:41:27.591Z (3 months ago)
- Language: JavaScript
- Size: 271 KB
- Stars: 4
- Watchers: 10
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
architect-restify [![build status](https://secure.travis-ci.org/bimedia-fr/architect-restify.png)](https://travis-ci.org/bimedia-fr/architect-restify) [![NPM version](https://img.shields.io/npm/v/architect-restify.svg)](https://www.npmjs.com/package/architect-restify)
=================expose restify server *rest* as architect plugin.
### Installation
```sh
npm install --save architect-restify
```
### Config Format```js
{
"packagePath": "architect-restify",
port: process.env.PORT || 8080,
host: process.env.IP || "0.0.0.0"
}
```
Or With plugins :```js
{
packagePath: "architect-restify",
port: process.env.PORT || 8080,
host: process.env.IP || "0.0.0.0"
plugins: {
bodyParser : {
mapParams : false
}
}
}
```### Usage
Boot [Architect](https://github.com/c9/architect) :
```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;
}
console.log("app ready");
});
```Configure Architect with `config.js` :
```js
module.exports = [{
packagePath: "architect-restify",
port: process.env.PORT || 8080,
host: process.env.IP || "0.0.0.0"
}, './routes'];
```
And register your routes in `./routes/index.js` :```js
module.exports = function setup(options, imports, register) {
var rest = imports.rest;// register routes
rest.get('/catalogue', function (req, res, next) {
res.write("{'message':'hello, world'}");
res.end();
});
register();
};
// Consume rest plugin
module.exports.consumes=['rest'];
```### 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`)
* plugins: a hash containing either a [restify bundled plugin](http://mcavage.me/node-restify/#Bundled-Plugins) or a function that returns a plugin.