8000 JIT specialized code gen for route handlers · Issue #4 · aklinker1/zeta · GitHub
[go: up one dir, main page]

Skip to content

JIT specialized code gen for route handlers #4

Closed

Description

@aklinker1

"Compile" request handler functions to custom functions for each route instead of having a single big function that covers all possible cases.

Here's the basic setup:

const schema = { properties: { id: { type: 'number' } } };

function compileHandler(routePath, schema) {
  // 1. Build the logic as a string
  const code = `
    return function handler(req, res) {
      ${schema.properties.id ? 'if(typeof req.body.id !== "number") return res.error();' : ''}
      // Actual logic...
      res.send("Success");
    }
    //# sourceURL=routes/${routePath}.js 
  `;

  // 2. Generate the function
  return new Function(code)();
}

Activity

  1. changed the title [-]JIT specialized code gen[/-] [+]JIT specialized code gen for route handlers[/+] on Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0