Skip to content

Commit

Permalink
Add restify (node) (#276)
Browse files Browse the repository at this point in the history
* add restify (node)

* add restify to node targets on makefile

* add dockerfile for restify (node)
  • Loading branch information
waghanza committed Jun 24, 2018
1 parent a6a80a2 commit e647781
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ phoenix:
docker build -t phoenix elixir/phoenix

# --- node.js ---
node: express fastify polka rayo koa
node: express fastify polka rayo koa restify

express:
docker build -t express node/express
Expand All @@ -27,6 +27,9 @@ rayo:
koa:
docker build -t koa node/koa

restify:
docker build -t restify node/restify

# --- Objective-C ---
objc: criollo

Expand All @@ -36,7 +39,7 @@ criollo:


# --- Ruby ---
ruby: rails sinatra roda rack-routing flame
ruby: rails sinatra roda rack-routing flame hanami

# Rails
rails:
Expand All @@ -62,6 +65,10 @@ hanami:
flame:
docker build -t flame ruby/flame

# hanami
hanami:
docker build -t hanami ruby/hanami

# --- Crystal ---
crystal: kemal router.cr lucky amber spider-gazelle

Expand Down
11 changes: 11 additions & 0 deletions neph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ node:
- fastify
- polka
- rayo
- restify

elixir:
dependencies:
Expand Down Expand Up @@ -274,6 +275,16 @@ rayo:
- docker build -t rayo .
directory: node/rayo

koa:
commands:
- docker build -t koa .
directory: node/koa

restify:
commands:
- docker build -t restify
directory: node/restify

plug:
commands:
- docker build -t plug .
Expand Down
13 changes: 13 additions & 0 deletions node/restify/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node

RUN npm -g install pm2

WORKDIR /usr/src/app

COPY app.js package.json ./

RUN npm install

ENV NODE_ENV production

CMD pm2-runtime start app.js -i $(nproc)
26 changes: 26 additions & 0 deletions node/restify/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const restify = require('restify');

const server = restify.createServer();

server.use(restify.plugins.acceptParser(server.acceptable));
server.use(restify.plugins.queryParser());
server.use(restify.plugins.bodyParser());

server.get('/', function (req, res, next) {
res.send();
return next();
});

server.get('/user/:id', function (req, res, next) {
res.send(req.params.id);
return next();
});

server.post('/user', function (req, res, next) {
res.send();
return next();
});

server.listen(3000, function () {
console.log('%s listening at %s', server.name, server.url);
});
5 changes: 5 additions & 0 deletions node/restify/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"restify": "7.2.1"
}
}
1 change: 1 addition & 0 deletions tools/src/benchmarker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ LANGS = [
{name: "polka", repo: "lukeed/polka"},
{name: "rayo", repo: "GetRayo/rayo.js"},
{name: "koa", repo: "koajs/koa"},
{name: "restify", repo: "restify/node-restify"},
]},
{lang: "elixir", targets: [
{name: "plug", repo: "elixir-lang/plug"},
Expand Down

0 comments on commit e647781

Please sign in to comment.