-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (25 loc) · 772 Bytes
/
index.js
File metadata and controls
31 lines (25 loc) · 772 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
30
31
const express = require('express');
const i18n = require('i18n');
const bodyParser = require('body-parser');
const dotenv = require('dotenv');
const fulfillment = require('./src/fulfillment');
const webhook = require('./src/webhookMessenger');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(i18n.init);
dotenv.config();
i18n.configure({
// codes of different languages
locales: ['en', 'nl', 'fr', 'es', 'de'],
directory: `${__dirname}/locales`,
defaultLocale: 'en',
});
// API
app.post('/api', fulfillment);
app.get('/webhook', webhook.get);
app.post('/webhook', webhook.post);
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`App listening on port ${port}`);
});