From 6bb2114d3382f13d59e8f8b2444dbb5f88a98e7e Mon Sep 17 00:00:00 2001 From: Justin xzHome Date: Sun, 6 Jul 2025 13:21:29 +0900 Subject: [PATCH] productRoutes added --- api/src/index.ts | 12 ++++++++---- api/src/routes/products/index.ts | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 api/src/routes/products/index.ts diff --git a/api/src/index.ts b/api/src/index.ts index fa2c7e2..6527e49 100644 --- a/api/src/index.ts +++ b/api/src/index.ts @@ -1,14 +1,18 @@ import express from 'express'; +import ProductsRoutes from './routes/products/index' const app = express(); const port = 3000; app.get('/', (req, res) => { - res.send('Hello World! 123') -}) + res.send('Hello World! 123'); +}); + + +app.use ('/products', ProductsRoutes); app.listen(port, () => { - console.log(`Example app listening on port ${port}`) -}) + console.log(`Example app listening on port ${port}`); +}); // comment test \ No newline at end of file diff --git a/api/src/routes/products/index.ts b/api/src/routes/products/index.ts new file mode 100644 index 0000000..3d03be6 --- /dev/null +++ b/api/src/routes/products/index.ts @@ -0,0 +1,19 @@ +import { Router } from "express"; + +const router = Router(); + +// products endpoints +router.get('/', (req,res) => { + res.send('the list of products from routes-products'); +}); + +router.get('/:id', (req,res) => { + console.log(req.params); + res.send('a product'); +}); + +router.post('/', (req,res) => { + res.send('New product created'); +}); + +export default router; \ No newline at end of file