Nicolas Massé 8 years ago
parent
commit
0ff1ec614a
  1. 25
      openapi-spec.yaml
  2. 25
      server.js

25
openapi-spec.yaml

@ -3,23 +3,28 @@ swagger: 2.0
info: info:
title: Summit API title: Summit API
description: An API that gives information about the Red Hat Summit. description: An API that gives information about the Red Hat Summit.
version: 2.0.0 version: 1.0.0
paths: paths:
/location: /location:
get: get:
summary: Get Next RH Summit Location summary: Get Next RH Summit Location
description: 'Get the location of the next RedHat Summit ' description: 'Get the location of the next RedHat Summit '
operationId: GetLocation operationId: GetLocation
x-threescale-smoketests-operation: true
responses: responses:
200: 200:
description: OK description: OK
security: /timeframe:
- oidc: get:
- openid summary: Get Next RH Summit Timeframe
description: Get the timeframe of the next RedHat Summit.
operationId: GetTimeframe
responses:
200:
description: OK
securityDefinitions: securityDefinitions:
oidc: apikey:
type: oauth2 name: api-key
flow: accessCode in: header
scopes: type: apiKey
openid: Get an OpenID Connect token security:
- apikey: []

25
server.js

@ -3,29 +3,40 @@ var app = express();
var router = express.Router(); var router = express.Router();
var port = 8080; var port = 8080;
router.use(function (req,res,next) { router.use(function (req, res, next) {
next(); next();
console.log("%s %s => %i", req.method, req.originalUrl, res.statusCode); console.log("%s %s => %i", req.method, req.originalUrl, res.statusCode);
}); });
router.get("/",function(req,res){ router.get("/location", function(req, res) {
res.sendFile(__dirname + '/views/index.html'); var response = { "Location": "SFO" };
res.type('application/json')
.send(JSON.stringify(response))
.end();
}); });
router.get("/location",function(req,res){ router.get("/timeframe",function(req, res) {
var response = { "Location": "SFO" }; var response = { "From": "08/05/2018", "To": "10/05/2018" };
res.type('application/json') res.type('application/json')
.send(JSON.stringify(response)) .send(JSON.stringify(response))
.end(); .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("/",router);
app.use("*",function(req,res){ app.use("*",function(req, res) {
res.status(404).send("Not found"); res.status(404).send("Not found");
}); });
app.listen(port,function(){ app.listen(port, function() {
console.log("Live at Port %i", port); console.log("Live at Port %i", port);
}); });

Loading…
Cancel
Save