Compare commits

...

2 Commits

Author SHA1 Message Date
Justin xzHome
afc8530b43 productsController added 2025-07-06 13:42:46 +09:00
Justin xzHome
6bb2114d33 productRoutes added 2025-07-06 13:21:29 +09:00
3 changed files with 47 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,18 @@
import { Router } from "express";
import { listProducts,
getProductById,
createProduct,
updateProduct,
deleteProduct
} from "./productsController";
const router = Router();
// products endpoints
router.get('/', listProducts);
router.get('/:id', getProductById);
router.post('/', createProduct);
router.put('/:id', updateProduct);
router.delete('/:id', deleteProduct);
export default router;

View File

@@ -0,0 +1,21 @@
import {Request, Response} from 'express';
export function listProducts(req: Request, res: Response) {
res.send ('listProducts');
}
export function getProductById(req: Request, res: Response) {
res.send ('getProductById');
}
export function createProduct(req: Request, res: Response) {
res.send ('createProduct');
}
export function updateProduct(req: Request, res: Response) {
res.send ('updateProduct');
}
export function deleteProduct(req: Request, res: Response) {
res.send ('deleteProduct');
}