Commit ed656d25 authored by Mike Shoup's avatar Mike Shoup

Add basic node.js REST API

parent b41df72a
var express = require("express");
var app = express();
var routes = require("./routes/routes.js")(app);
var server = app.listen(8000, function () {
console.log("Listening on port %s...", server.address().port);
});
{
"name": "helloapi",
"version": "1.0.0",
"description": "A Hello World Rest API",
"author": "Mike Shoup",
"dependencies": {
"express": "^4.16.3"
}
}
var appRouter = function(app) {
app.get("/hello", function(req, res) {
message = { hello: "world" };
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(message));
});
}
module.exports = appRouter;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment