Basic api status
This commit is contained in:
parent
1660cde4d4
commit
15ed3f11b4
2 changed files with 32 additions and 3 deletions
21
server/api.js
Normal file
21
server/api.js
Normal file
|
@ -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!');
|
||||
// });
|
|
@ -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('<h1>404 - Daaaa</h1>Not Here - Yo!');
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue