-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconApp.js
73 lines (73 loc) · 2.46 KB
/
conApp.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
System.register("util", ["path", "fs"], function (exports_1, context_1) {
"use strict";
var path, fs;
var __moduleName = context_1 && context_1.id;
function loadData() {
var raw = fs.readFileSync(process.env.HOME_DIR + 'data.json');
var dataAll = JSON.parse(raw.toString());
return dataAll;
}
exports_1("loadData", loadData);
function loadEnv() {
process.env.HOME_DIR = path.resolve(__dirname, '../') + "/";
require('dotenv').config({ path: process.env.HOME_DIR + ".env" });
}
exports_1("loadEnv", loadEnv);
return {
setters: [
function (path_1) {
path = path_1;
},
function (fs_1) {
fs = fs_1;
}
],
execute: function () {
}
};
});
System.register("app", ["express", "@line/bot-sdk", "util"], function (exports_2, context_2) {
"use strict";
var express, bot_sdk_1, util_1, dataAll, app, config;
var __moduleName = context_2 && context_2.id;
return {
setters: [
function (express_1) {
express = express_1;
},
function (bot_sdk_1_1) {
bot_sdk_1 = bot_sdk_1_1;
},
function (util_1_1) {
util_1 = util_1_1;
}
],
execute: function () {
util_1.loadEnv();
dataAll = util_1.loadData();
console.log(dataAll);
// Create a new express application instance
app = express();
config = {
channelAccessToken: process.env.CHANNEL_ACCESS_TOKEN,
channelSecret: process.env.CHANNEL_SECRET
};
app.get('/', function (req, res) {
res.send('Hello World!');
console.log('asdaffdffssdafsdafadffdsdafsdd');
});
// app.post('/webhook', (req, res) => {
// res.json({'test': 'ssdafdas'})
// })
app.post('/webhook', bot_sdk_1.middleware(config), function (req, res) {
var obj = req.body.events; // webhook event objects
var dest = req.body.destination; // user ID of the bot (optional)
console.log(obj, dest);
var user_id = obj.source.userId;
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
}
};
});