From 0ff1ec614a2949b7fef64eed0395e16953982b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Wed, 2 May 2018 14:12:49 +0200 Subject: [PATCH] v1 --- openapi-spec.yaml | 25 +++++++++++++++---------- server.js | 25 ++++++++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/openapi-spec.yaml b/openapi-spec.yaml index 79b0abf..da62b84 100644 --- a/openapi-spec.yaml +++ b/openapi-spec.yaml @@ -3,23 +3,28 @@ swagger: 2.0 info: title: Summit API description: An API that gives information about the Red Hat Summit. - version: 2.0.0 + version: 1.0.0 paths: /location: get: summary: Get Next RH Summit Location description: 'Get the location of the next RedHat Summit ' operationId: GetLocation - x-threescale-smoketests-operation: true responses: 200: description: OK -security: -- oidc: - - openid + /timeframe: + get: + summary: Get Next RH Summit Timeframe + description: Get the timeframe of the next RedHat Summit. + operationId: GetTimeframe + responses: + 200: + description: OK securityDefinitions: - oidc: - type: oauth2 - flow: accessCode - scopes: - openid: Get an OpenID Connect token + apikey: + name: api-key + in: header + type: apiKey +security: +- apikey: [] diff --git a/server.js b/server.js index df8f9c4..c89dbc6 100644 --- a/server.js +++ b/server.js @@ -3,29 +3,40 @@ var app = express(); var router = express.Router(); var port = 8080; -router.use(function (req,res,next) { +router.use(function (req, res, next) { next(); console.log("%s %s => %i", req.method, req.originalUrl, res.statusCode); }); -router.get("/",function(req,res){ - res.sendFile(__dirname + '/views/index.html'); +router.get("/location", function(req, res) { + var response = { "Location": "SFO" }; + res.type('application/json') + .send(JSON.stringify(response)) + .end(); }); -router.get("/location",function(req,res){ - var response = { "Location": "SFO" }; +router.get("/timeframe",function(req, res) { + var response = { "From": "08/05/2018", "To": "10/05/2018" }; res.type('application/json') .send(JSON.stringify(response)) .end(); }); +/* +router.get("/participants",function(req, res) { + var response = [ "Mark", "Nicolas" ]; + res.type('application/json') + .send(JSON.stringify(response)) + .end(); +}); +*/ app.use("/",router); -app.use("*",function(req,res){ +app.use("*",function(req, res) { res.status(404).send("Not found"); }); -app.listen(port,function(){ +app.listen(port, function() { console.log("Live at Port %i", port); });