-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (30 loc) · 893 Bytes
/
server.js
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
34
35
36
37
const express = require('express');
const cors = require('cors')
const app = express();
const port = process.env.PORT || 3000;
const messages = require('./messages');
// enable parsing of JSON bodies in request
app.use(express.json());
app.use(express.static('public'));
app.use(cors());
// define a route to retrieve all items
app.get('/api/messages', (req, res) => {
res.json(messages);
});
// set the view engine to EJS
app.set('view engine', 'ejs');
app.get('/', (req, res) => {
// render the 'index' template, and pass in a title and message
res.render('pages/index', {
title: 'Powered By VMware Tanzu Application Platform',
client: messages.client,
framework: messages.framework
});
});
app.get('/health', (req, res) => {
res.sendStatus(200);
});
app.listen(port, () => {
console.log(`app listening at http://localhost:${port}`);
});
module.exports = app;