-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* restore hapijs * add hapi to make targets
- Loading branch information
Showing
6 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters