Skip to content

Commit 855afb7

Browse files
authored
Restore hapijs (#306)
* restore hapijs * add hapi to make targets
1 parent 3680931 commit 855afb7

File tree

6 files changed

+88
-1
lines changed

6 files changed

+88
-1
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ phoenix:
1010
docker build -t phoenix elixir/phoenix
1111

1212
# --- node.js ---
13-
node: express fastify polka rayo koa restify
13+
node: express fastify polka rayo koa restify hapi
1414

1515
express:
1616
docker build -t express node/express
@@ -30,6 +30,9 @@ koa:
3030
restify:
3131
docker build -t restify node/restify
3232

33+
hapi:
34+
docker build -t hapi node/hapi
35+
3336
# --- Objective-C ---
3437
objc: criollo
3538

neph.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ node:
7474
- rayo
7575
- koa
7676
- restify
77+
- hapi
7778

7879
elixir:
7980
dependencies:
@@ -291,6 +292,12 @@ restify:
291292
- docker build -t restify .
292293
directory: node/restify
293294

295+
hapi:
296+
commands:
297+
- docker build -t hapi .
298+
directory: node/hapi
299+
300+
294301
plug:
295302
commands:
296303
- docker build -t plug .

node/hapi/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node
2+
3+
RUN npm -g install pm2
4+
5+
WORKDIR /usr/src/app
6+
7+
COPY app.js package.json ./
8+
9+
RUN npm install
10+
11+
ENV NODE_ENV production
12+
13+
CMD pm2-runtime start app.js -i $(nproc)

node/hapi/app.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"use strict";
2+
3+
const Hapi = require("hapi");
4+
5+
// Create a server with a host and port
6+
const server = Hapi.server({
7+
host: "0.0.0.0",
8+
port: 3000
9+
});
10+
11+
// Add the route
12+
server.route({
13+
method: "GET",
14+
path: "/",
15+
handler: function(req, handler) {
16+
return "";
17+
}
18+
});
19+
20+
server.route({
21+
method: "GET",
22+
path: "/user/{id}",
23+
handler: function(req, handler) {
24+
return req.params.id;
25+
}
26+
});
27+
28+
server.route({
29+
method: "POST",
30+
path: "/user",
31+
handler: function(req, handler) {
32+
return "";
33+
}
34+
});
35+
36+
// Start the server
37+
async function start() {
38+
try {
39+
await server.start();
40+
} catch (err) {
41+
console.log(err);
42+
process.exit(1);
43+
}
44+
45+
console.log("Server running at:", server.info.uri);
46+
}
47+
48+
start();

node/hapi/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "express",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "app.js",
6+
"dependencies": {
7+
"hapi": "17.5.1"
8+
},
9+
"devDependencies": {},
10+
"scripts": {
11+
"test": "echo \"Error: no test specified\" && exit 1"
12+
},
13+
"author": "",
14+
"license": "ISC"
15+
}

tools/src/benchmarker.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ LANGS = [
7979
{name: "rayo", repo: "GetRayo/rayo.js"},
8080
{name: "koa", repo: "koajs/koa"},
8181
{name: "restify", repo: "restify/node-restify"},
82+
{name: "hapi", repo: "hapijs/hapi"},
8283
]},
8384
{lang: "elixir", targets: [
8485
{name: "plug", repo: "elixir-lang/plug"},

0 commit comments

Comments
 (0)