-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
62 lines (51 loc) · 1.26 KB
/
app.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
let SERVER_URL = '';
// Load Development Variables
if (
process.env.NODE_ENV === undefined ||
process.env.NODE_ENV === 'DEVELOPMENT'
) {
require('dotenv').config();
} else {
SERVER_URL = process.env.SERVER_URL;
}
const PORT = process.env.PORT;
const express = require('express');
const morgan = require('morgan');
const routes = require('./routes/index.js');
const app = express();
// morgan logger
app.use(morgan('short'));
// Public folder
app.use(express.static('public'));
// Parse incoming JSON
app.use(
express.urlencoded({
extended: true,
})
);
// Set routes
routes(app);
// Set ejs as view engine
app.set('view engine', 'ejs');
app.set('view options', {
delimiter: '?',
});
app.set('port', PORT);
app.listen(PORT, async function () {
const ngrokModule = require('./lib_modules/utils/ngrokmodule.js');
SERVER_URL = await ngrokModule.GetNgrokUrl();
console.log(`Server is running at URL ${SERVER_URL}`);
});
async function GetAPIDetails() {
let data = {
mydata: 'mydata',
};
let fetchResponse = await fetch('URL', {
method: 'POST', // or 'PUT'
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
// Display RESULTS to screen
}