brisa-build / brisa

The Web Platform Framework.
https://brisa.build
MIT License
452 stars 12 forks source link

create `getServer` API to get access to protocol, origin, web sockets, etc #578

Closed aralroca closed 1 month ago

aralroca commented 1 month ago

The idea came from the conversation on this issue: https://github.com/brisa-build/brisa/issues/576#issuecomment-2429411123

import { getServer } from 'brisa/server';

// ...
const server = getServer();
/* 
DebugHTTPServer {
  address: {
    address: "::",
    family: "IPv6",
    port: 63621,
  },
  development: true,
  fetch: [Function: fetch],
  hostname: "localhost",
  id: "",
  pendingRequests: 3,
  pendingWebSockets: 1,
  port: 63621,
  protocol: "http",
  publish: [Function: publish],
  ref: [Function: ref],
  reload: [Function: reload],
  requestIP: [Function: requestIP],
  stop: [Function: stop],
  subscriberCount: [Function: subscriberCount],
  timeout: [Function: timeout],
  unref: [Function: unref],
  upgrade: [Function: upgrade],
  url: URL {
    href: "http://localhost:63621/",
    origin: "http://localhost:63621",
    protocol: "http:",
    username: "",
    password: "",
    host: "localhost:63621",
    hostname: "localhost",
    port: "63621",
    pathname: "/",
    hash: "",
    search: "",
    searchParams: URLSearchParams {},
    toJSON: [Function: toJSON],
    toString: [Function: toString],
  },
  [Symbol(Symbol.dispose)]: [Function: dispose],
  */