-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
300 additions
and
339 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
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 |
---|---|---|
@@ -1,5 +1,38 @@ | ||
import { router } from "@/handler"; | ||
import { Hono } from "hono"; | ||
import { Env } from "./worker-configuration"; | ||
import assetRoute from "./routes/asset/assetRoute"; | ||
import discordRoute from "./routes/discord/discordRoute"; | ||
import ocGeneratorRoute from "./routes/oc-generators/ocGeneratorRoutes"; | ||
import searchRoute from "./routes/search/searchRoute"; | ||
import gamesRoute from "./routes/games/gamesRoute"; | ||
import userRoute from "./routes/user/userRoute"; | ||
|
||
export default { | ||
fetch: router.handle, | ||
}; | ||
interface Bindings extends Env { | ||
[key: string]: unknown; | ||
} | ||
|
||
const app = new Hono<{ Bindings: Bindings }>(); | ||
|
||
app.get("/status", (c) => { | ||
c.status(200); | ||
return c.json({ status: "ok" }); | ||
}); | ||
app.get("/", (c) => { | ||
c.status(200); | ||
return c.json({ status: "ok", routes: app.routes }); | ||
}); | ||
app.route("/asset", assetRoute); | ||
app.route("/discord", discordRoute); | ||
app.route("/oc-generators", ocGeneratorRoute); | ||
app.route("/search", searchRoute); | ||
app.route("/games", gamesRoute); | ||
app.route("/user", userRoute); | ||
app.all("*", (c) => { | ||
c.status(404); | ||
return c.json({ status: "not found" }); | ||
}); | ||
|
||
// https://hono.dev/api/hono#showroutes | ||
app.showRoutes(); | ||
|
||
export default app; |
This file was deleted.
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
// helper function to create a 404 Not Found response | ||
export function createNotFoundResponse(errorMessage, responseHeaders) { | ||
const responseBody = { | ||
success: false, | ||
status: "error", | ||
error: "404 Not Found", | ||
message: errorMessage, | ||
}; | ||
|
||
return new Response(JSON.stringify(responseBody), { | ||
status: 404, | ||
headers: responseHeaders, | ||
}); | ||
return new Response( | ||
JSON.stringify({ | ||
success: false, | ||
status: "error", | ||
error: errorMessage, | ||
}), | ||
{ | ||
status: 404, | ||
headers: responseHeaders, | ||
} | ||
); | ||
} |
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
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 was deleted.
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,15 @@ | ||
import { Hono } from "hono"; | ||
import { getAssetFromId } from "./getAssetFromId"; | ||
import { downloadAsset } from "./downloadAsset"; | ||
|
||
const assetRoute = new Hono(); | ||
|
||
assetRoute.get("/:id", async (c) => { | ||
return getAssetFromId(c); | ||
}); | ||
|
||
assetRoute.get("/download/:assetId", async (c) => { | ||
return downloadAsset(c); | ||
}); | ||
|
||
export default assetRoute; |
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
Oops, something went wrong.