productRoutes added
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
import ProductsRoutes from './routes/products/index'
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = 3000;
|
const port = 3000;
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.send('Hello World! 123')
|
res.send('Hello World! 123');
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.use ('/products', ProductsRoutes);
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
console.log(`Example app listening on port ${port}`)
|
console.log(`Example app listening on port ${port}`);
|
||||||
})
|
});
|
||||||
|
|
||||||
// comment test
|
// comment test
|
||||||
19
api/src/routes/products/index.ts
Normal file
19
api/src/routes/products/index.ts
Normal 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;
|
||||||
Reference in New Issue
Block a user