-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (25 loc) · 821 Bytes
/
Copy pathapp.js
File metadata and controls
29 lines (25 loc) · 821 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
//Load Development Variables
if (
process.env.NODE_ENV === undefined ||
process.env.NODE_ENV === 'DEVELOPMENT'
) {
require('dotenv').config();
}
// Initialize the Viber Bot
let SERVER_URL = process.env.SERVER_URL;
let bot = require('./lib_modules/viber/botsetup.js');
// Initialize Express
const expresssetup = require('./lib_modules/utils/expressetup.js');
const app = expresssetup.app;
const PORT = expresssetup.PORT;
// Set routes
require('./routes/index.js')(app, bot);
app.listen(PORT, async function () {
if (process.env.NODE_ENV === 'DEVELOPMENT') {
const ngrok = require('./lib_modules/utils/ngrokmodule.js');
SERVER_URL = await ngrok.GetNgrokUrl();
}
// Attach the Webhook
bot.setWebhook(SERVER_URL);
console.log(`Server is running at URL ${SERVER_URL}`);
});