<commit_before>require('dotenv').config();
const express = require("express");
const linebot = require("linebot");
const chat = require("./chat.js");

// for test
var bodyParser = require('body-parser');

const PORT = process.env.PORT || 3123;
const HEWEATHER_KEY = process.env.heweather_key;

const bot = linebot({
  channelId: process.env.channelId,
  channelSecret: process.env.channelSecret,
  channelAccessToken: process.env.channelAccessToken
});

const proxy = require('http-proxy').createProxyServer({
    host: 'http://10.0.108.220:4001',
    // port: 80
});


//console.log(process.env.channelId, "\n", process.env.channelSecret, "\n", process.env.channelAccessToken);

bot.on('message', function(event) {
  if (event.message.type = 'text') {
    const msg = event.message.text;
    let r = chat.resolve(msg);
    if(null !== r) {
      r.then(res => event.reply(res));
    } 
  }
});

// Create our app
const app = express();
// const linebotParser = bot.parser();

app.use('/', function(req, res, next) {
    proxy.web(req, res, {
        target: 'http://10.0.108.220:4001'
    }, next);
});
//app.use(bodyParser.json());
// app.use(function (req, res, next) {
//   console.log("=== HEADER ===", JSON.stringify(req.headers, null, 2));
//   console.log("=== RAW BODY ===\n", req.rawBody);
//   console.log("=== BODY ===", JSON.stringify(req.body, null, 2));
//   next();
// });

// app.post('/', linebotParser);

app.listen(PORT, function () {
  console.log(`Express server is up on port ${PORT}`);
});<commit_msg>forward request<commit_after>require('dotenv').config();
const express = require("express");
const linebot = require("linebot");
const chat = require("./chat.js");

// for test
//var bodyParser = require('body-parser');

const PORT = process.env.PORT || 4321;
const HEWEATHER_KEY = process.env.heweather_key;

const bot = linebot({
  channelId: process.env.channelId,
  channelSecret: process.env.channelSecret,
  channelAccessToken: process.env.channelAccessToken
});

// const proxy = require('http-proxy').createProxyServer({
//     host: 'http://10.0.108.220:4001',
//     // port: 80
// });


//console.log(process.env.channelId, "\n", process.env.channelSecret, "\n", process.env.channelAccessToken);

bot.on('message', function(event) {
  if (event.message.type = 'text') {
    const msg = event.message.text;
    let r = chat.resolve(msg);
    if(null !== r) {
      r.then(res => event.reply(res));
    } 
  }
});

// Create our app
const app = express();
const linebotParser = bot.parser();

// === Proxy ===
// const httpProxy = require('http-proxy');
// app.use('/', function(req, res, next) {
//     httpProxy.web(req, res, {
//         target: 'http://10.0.108.220:4001'
//     }, next);
// });

//app.use(bodyParser.json());
// app.use(function (req, res, next) {
//   console.log("=== HEADER ===", JSON.stringify(req.headers, null, 2));
//   console.log("=== RAW BODY ===\n", req.rawBody);
//   console.log("=== BODY ===", JSON.stringify(req.body, null, 2));
//   next();
// });

// app.post('/', linebotParser);
app.post('/', function (req, res) {
  res.redirect("http://wman.ddns.net:4321/");
});

app.listen(PORT, function () {
  console.log(`Express server is up on port ${PORT}`);
});
{'fraction_non_alphanumeric': 0.21826625386996903, 'fraction_numerical': 0.022291021671826627, 'mean_word_length': 3.6025641025641026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7499921', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1097, 'n_words': 226}