API Lifecycle Demo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
948 B

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": "on-line" };
res.type('application/json')
.send(JSON.stringify(response))
.end();
});
router.get("/timeframe",function(req, res) {
var response = { "From": "13/11/2018", "To": "13/11/2018" };
res.type('application/json')
.send(JSON.stringify(response))
.end();
});
router.get("/participants",function(req, res) {
var response = [ "Nicolas", "David" ];
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);
});