Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.awfixer.me/llms.txt

Use this file to discover all available pages before exploring further.

Inside fetch, use the server.upgrade() function to upgrade an incoming Request to a WebSocket connection. JSTime automatically returns a 101 Switching Protocols response if the upgrade succeeds. Refer to the WebSocket docs for more information on building WebSocket servers.
const server = JSTime.serve<{ authToken: string }>({
  fetch(req, server) {
    const success = server.upgrade(req);
    if (success) {
      // JSTime automatically returns a 101 Switching Protocols
      // if the upgrade succeeds
      return undefined;
    }

    // handle HTTP request normally
    return new Response("Hello world!");
  },
  websocket: {
    // define websocket handlers
  },
});

console.log(`Listening on localhost:\${server.port}`);