Home / Function/ initServer() — react Function Reference

initServer() — react Function Reference

Architecture documentation for the initServer() function in run.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4514d839_66d1_e8e7_f330_2436b09aab29["initServer()"]
  e243e685_1a32_c31e_bb31_cb8b4ccc6d92["run.js"]
  4514d839_66d1_e8e7_f330_2436b09aab29 -->|defined in| e243e685_1a32_c31e_bb31_cb8b4ccc6d92
  style 4514d839_66d1_e8e7_f330_2436b09aab29 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fixtures/devtools/scheduling-profiler/run.js lines 38–75

function initServer() {
  const host = 'localhost';
  const port = 8000;

  const requestListener = function (request, response) {
    let contents;
    switch (request.url) {
      case '/react.js':
      case '/react-dom.js':
      case '/scheduler.js':
        response.setHeader('Content-Type', 'text/javascript');
        response.writeHead(200);
        contents = readFileSync(
          join(__dirname, DEPENDENCIES_DIRECTORY, request.url)
        );
        response.end(contents);
        break;
      case '/app.js':
        response.setHeader('Content-Type', 'text/javascript');
        response.writeHead(200);
        contents = readFileSync(join(__dirname, 'app.js'));
        response.end(contents);
        break;
      case '/index.html':
      default:
        response.setHeader('Content-Type', 'text/html');
        response.writeHead(200);
        contents = readFileSync(join(__dirname, 'index.html'));
        response.end(contents);
        break;
    }
  };

  const server = http.createServer(requestListener);
  server.listen(port, host, () => {
    console.log(`Server is running on http://${host}:${port}`);
  });
}

Domain

Subdomains

Frequently Asked Questions

What does initServer() do?
initServer() is a function in the react codebase, defined in fixtures/devtools/scheduling-profiler/run.js.
Where is initServer() defined?
initServer() is defined in fixtures/devtools/scheduling-profiler/run.js at line 38.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free