-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initialize deno api-vighnesh153
- Loading branch information
1 parent
dd900a3
commit 8a47309
Showing
7 changed files
with
79 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LOCAL_ONLY_UI_ORIGIN="http://localhost:4321" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"denoland.vscode-deno" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"deno.enablePaths": [ | ||
"./" | ||
], | ||
"editor.inlayHints.enabled": "off" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"imports": { | ||
"hono": "jsr:@hono/hono@^4.6.10" | ||
}, | ||
"tasks": { | ||
"start": "deno run --allow-env --allow-net --watch --env-file=.env.local.conf main.ts" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Hono } from "hono"; | ||
import { cors } from "hono/cors"; | ||
import { HTTPException } from "hono/http-exception"; | ||
|
||
const app = new Hono({ strict: false }); | ||
|
||
app.use(cors({ | ||
origin: Deno.env.get("LOCAL_ONLY_UI_ORIGIN") ?? "https://vighnesh153.dev", | ||
allowHeaders: ["content-type"], | ||
credentials: true, | ||
allowMethods: ["GET", "POST", "PUT", "DELETE"], | ||
maxAge: 24 * 3600, | ||
})); | ||
|
||
app.get("/", (c) => { | ||
return c.json({ | ||
message: "Pikachu 123 456", | ||
}); | ||
}); | ||
|
||
app.notFound((c) => { | ||
return c.json({ | ||
message: "Path not found!", | ||
}, 404); | ||
}); | ||
|
||
app.onError((err, c) => { | ||
console.error(`Error: "${err.message}"`, err); | ||
|
||
if (err instanceof HTTPException) { | ||
return err.getResponse(); | ||
} | ||
|
||
return c.json({ | ||
message: "Unhandled error!", | ||
}, 500); | ||
}); | ||
|
||
Deno.serve(app.fetch); |