-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (32 loc) · 1 KB
/
index.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
'use strict'
let express = require('express')
let app = express()
let bodyParser = require('body-parser')
// These two following lines ensures that every incomming request is parsed to json automatically
app.use(bodyParser.urlencoded({ extended: 'true' }))
app.use(bodyParser.json())
// Allowing access to resources from anywhere
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
next()
})
app.post('/', (req, res) => {
let response = {};
const intentName = req.body.queryResult.intent.displayName;
if (intentName === 'emploi_du_temps') {
response = {
fulfillmentText: "Tu n'a rien demain, branleur :)",
}
}
res.json(response);
})
app.get('/health', (req, res) => {
res.send("D'où tu téma ma santé batard !")
});
let port = process.env.PORT;
if (port == null || port == "") {
port = 8000;
}
app.listen(port)
console.log('info', `server listening on port ${port}`)