aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGravatar Jesse-Lucas1996 <61496789+Jesse-Lucas1996@users.noreply.github.com> 2022-07-12 17:46:22 +0800
committerGravatar GitHub <noreply@github.com> 2022-07-12 11:46:22 +0200
commita63a0ccc105039278faaf920940ffa737e9b98df (patch)
tree5b5b5a4a637a1b3e232571c8bbe6bd65c639e582 /examples
parent734775e4100fce92961a6f8dd6a8fd0ea45a68eb (diff)
downloadbun-a63a0ccc105039278faaf920940ffa737e9b98df.tar.gz
bun-a63a0ccc105039278faaf920940ffa737e9b98df.tar.zst
bun-a63a0ccc105039278faaf920940ffa737e9b98df.zip
docs: Hono example with typescript (#577)
* hono example with typescript * changing of name in package json * adding dom to lib * removal of git ignore * removed DOM * Update examples/hono/src/index.ts Co-authored-by: Hyro <generalkubo@gmail.com> * changed port * added read me * Update index.ts * Update package.json * Update readme.md Co-authored-by: Hyro <generalkubo@gmail.com> Co-authored-by: Jesse Lucas <jlucas@corpcloud.com.au> Co-authored-by: Finn R. Gärtner <65015656+FinnRG@users.noreply.github.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/hono/package.json14
-rw-r--r--examples/hono/readme.md17
-rw-r--r--examples/hono/src/index.ts16
-rw-r--r--examples/hono/tsconfig.json10
4 files changed, 57 insertions, 0 deletions
diff --git a/examples/hono/package.json b/examples/hono/package.json
new file mode 100644
index 000000000..10b123864
--- /dev/null
+++ b/examples/hono/package.json
@@ -0,0 +1,14 @@
+{
+ "version": "1.0.0",
+ "name": "hono",
+ "main": "src/index.js",
+ "devDependencies": {
+ "bun-types": "^0.0.83"
+ },
+ "dependencies": {
+ "hono": "^1.6.4"
+ },
+ "scripts": {
+ "start": "bun run src/index.ts"
+ }
+}
diff --git a/examples/hono/readme.md b/examples/hono/readme.md
new file mode 100644
index 000000000..992ca277e
--- /dev/null
+++ b/examples/hono/readme.md
@@ -0,0 +1,17 @@
+# Hono with Bun runtime
+
+## Getting Started
+
+### Cloning the repo
+
+```sh
+bun create hono ./NAME_HERE
+```
+
+### Development
+```
+bun run start
+```
+
+Open http://localhost:3000 with your browser to see the result.
+
diff --git a/examples/hono/src/index.ts b/examples/hono/src/index.ts
new file mode 100644
index 000000000..2bc0be21c
--- /dev/null
+++ b/examples/hono/src/index.ts
@@ -0,0 +1,16 @@
+import { Hono } from "hono";
+
+const app = new Hono();
+
+const port = process.env.PORT || 3000;
+
+const home = app.get("/", (c) => {
+ return c.json({ message: "Hello World!" });
+});
+
+console.log(`Running at http://localhost:${port}`);
+
+export default {
+ port: process.env.PORT || 3000,
+ fetch: home.fetch,
+};
diff --git a/examples/hono/tsconfig.json b/examples/hono/tsconfig.json
new file mode 100644
index 000000000..a3d4e525d
--- /dev/null
+++ b/examples/hono/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "compilerOptions": {
+ "lib": ["ESNext"],
+ "module": "esnext",
+ "target": "esnext",
+ "moduleResolution": "node",
+ // "bun-types" is the important part
+ "types": ["bun-types"]
+ }
+ } \ No newline at end of file