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:
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: []

25
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);
});

Loading…
Cancel
Save