diff --git a/server/api.js b/server/api.js new file mode 100644 index 0000000..da0d8a2 --- /dev/null +++ b/server/api.js @@ -0,0 +1,21 @@ +'use strict'; +var express = require('express'); +var router = express.Router(); + +// home page route (http://localhost:8080) +router.get('/status', function (req, res) { + var d = new Date(); + res.send({ + Status: "OK", + Mantra: "KISS - Yo!", + Time: d.toString() + }); +}); + + +module.exports = router; + +// // about page route (http://localhost:8080/about) +// router.get('/about', function(req, res) { +// res.send('im the about page!'); +// }); diff --git a/server/server.js b/server/server.js index c371ae0..7024b55 100644 --- a/server/server.js +++ b/server/server.js @@ -1,6 +1,7 @@ 'use strict'; var server; var express = require('express'); +var api = require('./api'); @@ -8,9 +9,16 @@ class Server { constructor() { console.log('Pin'); this.app = express(); - this.app.get('/', (req, res) => { - res.status(200) - .send('Hello, world - PIN PIN PIN!'); + this.app.use('/api', api); + // this.app.get('/', (req, res) => { + // res.status(200) + // .send('Hello, world - PIN PIN PIN!'); + // }); + + this.app.use((req, res, next) => { + res.statusCode = 404; + res.send('