This project is about an API built using NodeJs, Typescript, Docker, MongoDB.
Start by following these terminal commands:
$ git clone https://github.com/RafaelMariscal/jackedPlanner
$ cd api
$ yarn
You can set the both docker and api ports by the constants 'DOCKERPORT' and 'PORT' at index.ts file.
The connection with MongoDB was provided by a docker container, and to make the connection just run theses command lines into terminal:
docker run --name mongo -p 27017:27017 -d mongo
yarn add mongoose
-
The api will only run if it was stablish a conection with MongoDB by mongoose
-
To treat image uploads when creating products, it was used a miltiform request format, and it was used Multer as well
Just follow theses terminal command lines:
$ yarn build
$ yarn start
router.get("/categories", listCategories);
router.post("/categories", createCategory);
router.get("/products", listProducts);
router.post("/products", upload.single("image"), createProduct);
router.delete("/products/:productId", deleteProduct);
router.get("/categories/:categoryId/products", listProductsByCategory);
router.get("/orders", listOrders);
router.post("/orders", createOrder);
router.patch("/orders/:orderId", changeOrderStatus);
router.delete("/orders/:orderId", cancelOrder);