mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-11 05:36:10 -05:00
Routes folder structure
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
import { App } from "@tinyhttp/app";
|
||||
import { logger } from "@tinyhttp/logger";
|
||||
import routes from "../src/routes/index";
|
||||
|
||||
const app = new App();
|
||||
|
||||
const PORT = 3000;
|
||||
|
||||
app
|
||||
.use(logger())
|
||||
.get("/", (_, res) => void res.send("<h1>Hello World</h1>"))
|
||||
.get("/page/:page/", (req, res) => {
|
||||
res.status(200).send(`
|
||||
<h1>Some cool page</h1>
|
||||
<h2>URL</h2>
|
||||
${req.url}
|
||||
<h2>Params</h2>
|
||||
${JSON.stringify(req.params, null, 2)}
|
||||
`);
|
||||
})
|
||||
.listen(3000);
|
||||
.use(routes)
|
||||
.listen(PORT, () =>
|
||||
console.log(`Server ready at: https://localhost:${PORT}`)
|
||||
);
|
||||
|
||||
8
packages/server/src/routes/index.ts
Normal file
8
packages/server/src/routes/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { App } from "@tinyhttp/app";
|
||||
import tournament from "./tournaments.routes";
|
||||
|
||||
const routes = new App();
|
||||
|
||||
routes.use("/tournaments", tournament);
|
||||
|
||||
export default routes;
|
||||
7
packages/server/src/routes/tournaments.routes.ts
Normal file
7
packages/server/src/routes/tournaments.routes.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { App } from "@tinyhttp/app";
|
||||
|
||||
const app = new App();
|
||||
|
||||
app.get("/", (req, res) => res.send("Welcome"));
|
||||
|
||||
export default app;
|
||||
Reference in New Issue
Block a user