-
Notifications
You must be signed in to change notification settings - Fork 646
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add restify (node) * add restify to node targets on makefile * add dockerfile for restify (node)
- Loading branch information
Showing
6 changed files
with
65 additions
and
2 deletions.
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,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); | ||
}); |
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,5 @@ | ||
{ | ||
"dependencies": { | ||
"restify": "7.2.1" | ||
} | ||
} |
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