Browse Source

initial release

pull/1/head
Nicolas Massé 7 years ago
commit
94da960ffe
  1. 15
      package.json
  2. 40
      server.js

15
package.json

@ -0,0 +1,15 @@
{
"name": "rhte-api",
"version": "0.0.1",
"description": "A demo showing CI/CD with 3scale AMP",
"main": "server.js",
"scripts": {
"test": "true"
},
"author": "Nicolas MASSE",
"repository": "https://github.com/nmasse-itix/rhte-api.git",
"license": "MIT",
"dependencies": {
"express": "latest"
}
}

40
server.js

@ -0,0 +1,40 @@
var express = require("express");
var app = express();
var router = express.Router();
var port = 8080;
router.use(function (req, res, next) {
next();
console.log("%s %s => %i", req.method, req.originalUrl, res.statusCode);
});
router.get("/location", function(req, res) {
var response = { "Location": "Praha" };
res.type('application/json')
.send(JSON.stringify(response))
.end();
});
router.get("/timeframe",function(req, res) {
var response = { "From": "17/09/2018", "To": "21/09/2018" };
res.type('application/json')
.send(JSON.stringify(response))
.end();
});
/*
router.get("/participants",function(req, res) {
var response = [ "Manfred", "Nicolas" ];
res.type('application/json')
.send(JSON.stringify(response))
.end();
});
*/
app.use("/",router);
app.use("*",function(req, res) {
res.status(404).send("Not found");
});
app.listen(port, function() {
console.log("Live at Port %i", port);
});
Loading…
Cancel
Save