aboutsummaryrefslogtreecommitdiff
path: root/docs/api
diff options
context:
space:
mode:
Diffstat (limited to 'docs/api')
-rw-r--r--docs/api/http.md4
-rw-r--r--docs/api/utils.md26
2 files changed, 29 insertions, 1 deletions
diff --git a/docs/api/http.md b/docs/api/http.md
index 4cb55349a..3e11299dd 100644
--- a/docs/api/http.md
+++ b/docs/api/http.md
@@ -134,11 +134,13 @@ Bun.serve({
Thus far, the examples on this page have used the explicit `Bun.serve` API. Bun also supports an alternate syntax.
```ts#server.ts
+import {type Serve} from "bun";
+
export default {
fetch(req) {
return new Response(`Bun!`);
},
-};
+} satisfies Serve;
```
Instead of passing the server options into `Bun.serve`, export it. This file can be executed as-is; when Bun runs a file with a `default` export containing a `fetch` handler, it passes it into `Bun.serve` under the hood.
diff --git a/docs/api/utils.md b/docs/api/utils.md
index dcd9c0128..ce3d0d6f9 100644
--- a/docs/api/utils.md
+++ b/docs/api/utils.md
@@ -118,3 +118,29 @@ test("peek.status", () => {
expect(peek.status(rejected)).toBe("rejected");
});
```
+
+## `Bun.openInEditor`
+
+Open a file in your default editor. Bun auto-detects your editor via the `$VISUAL` or `$EDITOR` environment variables.
+
+```ts
+const currentFile = import.meta.url;
+Bun.openInEditor(currentFile);
+```
+
+You can override this via the `debug.editor` setting in your [`bunfig.toml`](/docs/project/configuration)
+
+```toml-diff#bunfig.toml
++ [debug]
++ editor = "code"
+```
+
+Or specify an editor with the `editor` param. You can also specify a line and column number.
+
+```ts
+Bun.openInEditor(import.meta.url, {
+ editor: "vscode", // or "subl"
+ line: 10,
+ column: 5,
+})
+```