-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
26 lines (22 loc) · 701 Bytes
/
Copy pathapp.js
File metadata and controls
26 lines (22 loc) · 701 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
const express = require("express");
const app = express();
const { PORT, CHANNEL } = require("./config");
const apiController = require("./controllers/Api");
const line = require("@line/bot-sdk");
const path = require("path");
// create config for LINE SDK
const config = {
channelAccessToken: CHANNEL.CHANNEL_ACCESS_TOKEN,
channelSecret: CHANNEL.CHANNEL_SECRET
};
// set static folder
app.use(express.static(path.join(__dirname, "public")));
app.get("/", (req, res) => {
res.status(200).json({
message: "Server is running"
});
});
app.post("/", line.middleware(config), apiController.lineApi);
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});