<commit_before>const express = require('express');
const path = require('path');
const httpProxy = require('http-proxy');
const favicon = require('serve-favicon');

// parse dashboard
const ParseDashboard = require('parse-dashboard');

class ServerInstance {
  constructor(settings) {
    this.settings = settings;
  }

  create() {
    return new Promise((resolve) => {
      const { settings } = this;
      const port = settings.port || 55555;
      const app = express();
      app.use(favicon(path.resolve(__dirname, '../public', 'favicon-32.png')));

      // Proxy to API server
      const targetUrl = 'http://localhost:' + (process.env.PARSE_PORT || 1337);
      const proxy = httpProxy.createProxyServer({
        target: targetUrl,
        ws: true
      });
      app.use('/api', (req, res) => {
        proxy.web(req, res, { target: targetUrl });
      });

      // parse dashboard
      const dashboard = new ParseDashboard({
        apps: [
          {
            serverURL: settings.serverURL || 'http://localhost:1337/parse',
            appId: settings.appId || 'myAppId',
            masterKey: settings.masterKey || 'masterKey',
            appName: 'dumbledore',
          }
        ],
        users: [
          {
            user: settings.user || 'parseapp',
            pass: settings.pass || '<PASSWORD>'
          }
        ],<commit_msg>Upgrade proxy server to socket server<commit_after>const express = require('express');
const path = require('path');
const httpProxy = require('http-proxy');
const favicon = require('serve-favicon');

// parse dashboard
const ParseDashboard = require('parse-dashboard');

class ServerInstance {
  constructor(settings) {
    this.settings = settings;
  }

  create() {
    return new Promise((resolve) => {
      const { settings } = this;
      const port = settings.port || 55555;
      const app = express();
      app.use(favicon(path.resolve(__dirname, '../public', 'favicon-32.png')));

      // Proxy to API server
      const targetUrl = 'http://localhost:' + (process.env.PARSE_PORT || 1337);
      const proxy = httpProxy.createProxyServer({
        target: targetUrl,
        ws: true
      });

      proxy.on('upgrade', function (req, socket, head) {
        proxy.ws(req, socket, head);
      });

      app.use('/api', (req, res) => {
        proxy.web(req, res, { target: targetUrl });
      });

      // parse dashboard
      const dashboard = new ParseDashboard({
        apps: [
          {
            serverURL: settings.serverURL || 'http://localhost:1337/parse',
            appId: settings.appId || 'myAppId',
            masterKey: settings.masterKey || 'masterKey',
            appName: 'dumbledore',
          }
        ],
        users: [
          {
            user: settings.user || 'parseapp',
            pass: settings.pass || '<PASSWORD>'
          }
        ],
{'fraction_non_alphanumeric': 0.14699720670391062, 'fraction_numerical': 0.01047486033519553, 'mean_word_length': 2.2263513513513513, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '53182', 'n_tokens_mistral': 836, 'n_tokens_neox': 798, 'n_words': 187}