-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
44 lines (35 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
'use strict';
require('dotenv').config();
/**
* DAO Section
* Initialize DB connection
* Initialize models
*/
const connect = require("./dao/connector");
// Open DB Connection
connect();
const Lesson = require('./dao/models/lesson');
const User = require('./dao/models/user');
const Question = require('./dao/models/question').Question;
const APIController = require('./controllers/APIController');
const constructTemplateResponse = require('./service/messengerService').constructTemplateResponse;
const seachMatchingPicture = require('./service/messengerService').seachMatchingPicture;
// Call seeder for sample lessons.
require('./dao/seeder/lessonSeeder');
/**
* Express Sections
* Imports dependencies and set up http server
*/
const
express = require('express'),
body_parser = require('body-parser'),
app = express().use(body_parser.json()); // creates express http server
// Webhook BOT routes
app.get('/webhook', APIController.verifyServer);
app.post('/webhook', APIController.handleWebhookEvent);
// Handles rendering of the user homepage
app.get('/render', function (req, res) {
APIController.renderHtml(req, res, User);
});
// Sets server port and logs message on success
app.listen(process.env.PORT || 1337, () => console.log('webhook is listening'));