diff --git a/Express/barAndCafe/src/app.ts b/Express/barAndCafe/src/app.ts new file mode 100644 index 0000000..943d8a9 --- /dev/null +++ b/Express/barAndCafe/src/app.ts @@ -0,0 +1,21 @@ +import express from "express"; + +/** + * Initialize Express application instance. + * @returns An initialized Express application object. + */ +const app = express(); + +/** + * Handle GET request for homepage route ('/'). + * Send back a simple text response. + * @param {express.Request} req - HTTP Request object. + * @param {express.Response} res - HTTP Response object. + */ +function getRoot(req: express.Request, res: express.Response) { + res.send("hello world from dev"); +} + +app.get("/", getRoot); + +export default app; \ No newline at end of file diff --git a/Express/barAndCafe/index.ts b/Express/barAndCafe/src/server.ts similarity index 61% rename from Express/barAndCafe/index.ts rename to Express/barAndCafe/src/server.ts index 7d6d177..625a94c 100644 --- a/Express/barAndCafe/index.ts +++ b/Express/barAndCafe/src/server.ts @@ -1,16 +1,10 @@ -import express from "express"; import * as dotenv from "dotenv"; +import app from "./app"; dotenv.config({path: '../../.env'}) const port = parseInt(process.env.BAR_PORT || '3000') -const app = express(); - -app.get("/", (req, res) => { - res.send("helloworld form dev") -}) - app.listen(port, () =>{ console.log(`serveur running in ${port}`) }) \ No newline at end of file