productRoutes added

This commit is contained in:
Justin xzHome
2025-07-06 13:21:29 +09:00
parent 4ea2d039ff
commit 6bb2114d33
2 changed files with 27 additions and 4 deletions

View File

@@ -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

View File

@@ -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;