Skip to content

Implement server.url - #7043

Merged
Jarred-Sumner merged 2 commits into
mainfrom
server-url
Nov 11, 2023
Merged

Jarred-Sumner merged 2 commits into
mainfrom
server-url

Conversation

@Electroid

@Electroid Electroid commented Nov 11, 2023 •

Copy link
Copy Markdown
Contributor

What does this PR do?

This adds support for server.url from Bun.serve().

const server = Bun.serve({
  fetch() {
    return new Response();
  }
});

console.log(server.url instanceof URL); // true
console.log(server.url.protocol); // "http:"
console.log(server.url.hostname); // "localhost"
console.log(server.url.port); // 3000

For unix sockets, it also works.

const server = Bun.serve({
  unix: "/tmp/bun.sock",
  fetch() {
    return new Response();
  }
});

console.log(server.url instanceof URL); // true
console.log(server.url.protocol); // "unix:"
console.log(server.url.pathname); // "/tmp/bun.sock"
  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

Closes #5758, #6064

@github-actions

Copy link
Copy Markdown
Contributor

❌ @Electroid 5 files with test failures on bun-darwin-aarch64:

  • test/bundler/esbuild/default.test.ts
  • test/integration/next/default-pages-dir/test/dev-server.test.ts
  • test/js/bun/test/test-test.test.ts
  • test/js/bun/util/which.test.ts
  • test/js/web/worker.test.ts

View test output

#e781c3e99f50721ee727b953393eebe500df339c

@github-actions

Copy link
Copy Markdown
Contributor

❌ @Electroid 7 files with test failures on bun-darwin-x64-baseline:

  • test/js/bun/spawn/spawn-streaming-stdout.test.ts
  • test/js/bun/util/which.test.ts
  • test/js/node/fs/fs.test.ts
  • test/js/node/watch/fs.watchFile.test.ts
  • test/js/third_party/webpack/webpack.test.ts
  • test/js/web/timers/setInterval.test.js
  • test/js/web/timers/setTimeout.test.js

View test output

#e781c3e99f50721ee727b953393eebe500df339c

@github-actions

Copy link
Copy Markdown
Contributor

❌ @Electroid 6 files with test failures on bun-darwin-x64:

  • test/js/bun/spawn/spawn-streaming-stdout.test.ts
  • test/js/bun/util/which.test.ts
  • test/js/node/fs/fs.test.ts
  • test/js/node/watch/fs.watchFile.test.ts
  • test/js/third_party/webpack/webpack.test.ts
  • test/js/web/timers/setTimeout.test.js

View test output

#e781c3e99f50721ee727b953393eebe500df339c

@Jarred-Sumner
Jarred-Sumner merged commit f0cbc79 into main Nov 11, 2023
@Jarred-Sumner
Jarred-Sumner deleted the server-url branch November 11, 2023 07:00
@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

yay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement server.url

2 participants