diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 52e8d14c2..56caf5351 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -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("

Hello World

")) - .get("/page/:page/", (req, res) => { - res.status(200).send(` -

Some cool page

-

URL

- ${req.url} -

Params

- ${JSON.stringify(req.params, null, 2)} - `); - }) - .listen(3000); + .use(routes) + .listen(PORT, () => + console.log(`Server ready at: https://localhost:${PORT}`) + ); diff --git a/packages/server/src/routes/index.ts b/packages/server/src/routes/index.ts new file mode 100644 index 000000000..1196216ca --- /dev/null +++ b/packages/server/src/routes/index.ts @@ -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; diff --git a/packages/server/src/routes/tournaments.routes.ts b/packages/server/src/routes/tournaments.routes.ts new file mode 100644 index 000000000..94d21e57b --- /dev/null +++ b/packages/server/src/routes/tournaments.routes.ts @@ -0,0 +1,7 @@ +import { App } from "@tinyhttp/app"; + +const app = new App(); + +app.get("/", (req, res) => res.send("Welcome")); + +export default app;