-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroutes.js
32 lines (27 loc) · 898 Bytes
/
routes.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
import express from 'express'
import path from 'path'
const Router = express.Router()
import bodyParser from 'body-parser'
import chatMessage from './lib/sms-chat/chatMessage'
import welcomeMessage from './lib/sms-notify/welcomeMessage'
// Middleware
Router.use(bodyParser.json())
Router.use(bodyParser.urlencoded({ extended: true }))
Router.use((req, res, next) => {
res.header('Access-Control-Allow-Origin': 'https://pelhage.github.io/eaze-up')
res.header('Access-Control-Allow-Methods': 'GET, POST')
next()
})
Router.use('/eaze-up', express.static('dist'));
// API
Router.get('/', function(req, res) {
// console.log('Doing it...');
res.sendFile(path.join(__dirname + '/index.html'))
// res.send('Hello')
// res.send('Hello')
})
// The chat bot interface:
Router.post('/message', chatMessage)
// Upon text request
Router.post('/welcome', welcomeMessage)
export default Router