Skip to content

Commit

Permalink
Restore hapijs (#306)
Browse files Browse the repository at this point in the history
* restore hapijs

* add hapi to make targets
  • Loading branch information
waghanza committed Jul 27, 2018
1 parent 3680931 commit 855afb7
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 1 deletion.
5 changes: 4 additions & 1 deletion 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 restify
node: express fastify polka rayo koa restify hapi

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

hapi:
docker build -t hapi node/hapi

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

Expand Down
7 changes: 7 additions & 0 deletions neph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ node:
- rayo
- koa
- restify
- hapi

elixir:
dependencies:
Expand Down Expand Up @@ -291,6 +292,12 @@ restify:
- docker build -t restify .
directory: node/restify

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


plug:
commands:
- docker build -t plug .
Expand Down
13 changes: 13 additions & 0 deletions node/hapi/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)
48 changes: 48 additions & 0 deletions node/hapi/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"use strict";

const Hapi = require("hapi");

// Create a server with a host and port
const server = Hapi.server({
host: "0.0.0.0",
port: 3000
});

// Add the route
server.route({
method: "GET",
path: "/",
handler: function(req, handler) {
return "";
}
});

server.route({
method: "GET",
path: "/user/{id}",
handler: function(req, handler) {
return req.params.id;
}
});

server.route({
method: "POST",
path: "/user",
handler: function(req, handler) {
return "";
}
});

// Start the server
async function start() {
try {
await server.start();
} catch (err) {
console.log(err);
process.exit(1);
}

console.log("Server running at:", server.info.uri);
}

start();
15 changes: 15 additions & 0 deletions node/hapi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "express",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"hapi": "17.5.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
1 change: 1 addition & 0 deletions tools/src/benchmarker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ LANGS = [
{name: "rayo", repo: "GetRayo/rayo.js"},
{name: "koa", repo: "koajs/koa"},
{name: "restify", repo: "restify/node-restify"},
{name: "hapi", repo: "hapijs/hapi"},
]},
{lang: "elixir", targets: [
{name: "plug", repo: "elixir-lang/plug"},
Expand Down

0 comments on commit 855afb7

Please sign in to comment.