-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (26 loc) · 726 Bytes
/
server.js
File metadata and controls
33 lines (26 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const express = require('express');
const servicedata = require('./src/service')
// Setup
const server = express();
const port = 3000;
// Create main endpoint
server.get('/', (request, response) =>{
response.send('<h1>Hello from Express</h1>')
});
// Create heath endpoint
let health = servicedata.health();
server.get('/health', (req, res) => {
res.contentType('text/plain');
res.send(health);
});
// Create metadata endpoint
let metadata = servicedata.metadata();
server.get('/metadata', (req, res) => {
res.contentType('application/json');
res.send(metadata);
});
// Start Server
server.listen(port);
console.log(`Service starting on port ${port}`);
// Export for testing
module.exports = server;