const express = require("express"); const bodyParser = require("body-parser"); const upload = require('../middlewares/upload'); const blogUserValidater = require('../validations/blogValidations'); const commentValidater = require('../validations/commentsValidation'); const categoryValidater = require('../validations/categoryValidation'); const tagValidater = require('../validations/tagValidation'); const { createBlog, getBlogs, updateBlog, deleteBlog, } = require("../controller/blog.controller"); const { createComments, getComments, updateComments, deleteComments, } = require("../controller/comments.controller"); const { createTags, getTags, updateTags, deleteTags, } = require("../controller/tags.controller"); const { createCategory, getCategory, updateCategory, deleteCategory, } = require("../controller/category.controller"); const { bulkUploadBlogs } = require("../controller/bulkUpload.controller"); const app = express(); app.use(bodyParser.json()); const PORT = 3000; //-----------------------------Blogs----------------------------- app.post("/blogs", upload.single("coverImage"), blogUserValidater, createBlog); app.get("/api/blogs", getBlogs); app.put("/api/blogs/:id", updateBlog); app.delete("/api/blogs/:id", deleteBlog); app.post("/api/blogs/bulkBlog", upload.single("file"), bulkUploadBlogs); //-----------------------------Comments----------------------------- app.post("/api/comment", commentValidater, createComments); app.get("/api/comment", getComments); app.put("/api/comment/:id", updateComments); app.delete("/api/comment/:id", deleteComments); //-----------------------------Categories----------------------------- app.post("/api/category", categoryValidater, createCategory); app.get("/api/category", getCategory); app.put("/api/category/:id", updateCategory); app.delete("/api/category/:id", deleteCategory); //-----------------------------Tags----------------------------- app.post("/api/tags", tagValidater, createTags); app.get("/api/tags", getTags); app.put("/api/tags/:id", updateTags); app.delete("/api/tags/:id", deleteTags); app.listen(PORT, () => { console.log( `Your Server is Successfully running on http://localhost:${PORT} ` ); });