Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- const express = require('express');
- const Linebot = require('./linebot.js');
- const app = express();
- const linebot = new Linebot();
- //const ai = new AI();
- app.get('/', (req, res) => {
- res.json({
- api: 'lineBot'
- });
- });
- app.post('/linebot/callback',
- linebot.getMiddleware(), (req, res) => {
- Promise.all(req.body.events.map(linebot.handleEvent.bind(linebot)))
- .then(result => {
- return res.json(result)
- })
- .catch(err => {
- console.error(err);
- res.status(500).end();
- });
- });
- const port = process.env.PORT || 8100;
- app.listen(port, () => {
- console.log(`listening on ${port}`);
- });
Add Comment
Please, Sign In to add comment