1719 lines
59 KiB
JavaScript
1719 lines
59 KiB
JavaScript
const { isVoter } = require("../authentication");
|
|
const { Router } = require("express");
|
|
const router = Router();
|
|
|
|
/////////////////////////////////////////////////////////// controllers
|
|
const categoryController = require("../controllers/categoryController");
|
|
const newsController = require("../controllers/newsController");
|
|
const galleryController = require("../controllers/galleryController");
|
|
const contentController = require("../controllers/contentController");
|
|
const commentController = require("../controllers/commentController");
|
|
const newsFileController = require("../controllers/newsFileController");
|
|
const linksController = require("../controllers/linksController");
|
|
const sliderController = require("../controllers/sliderController");
|
|
const homeController = require("../controllers/homeController");
|
|
const yearBannerController = require("../controllers/yearBannerController");
|
|
const counterDayController = require("../controllers/counterDayController");
|
|
const captchaController = require("../controllers/captchaController");
|
|
const dataBackupController = require("../controllers/dataBackupController");
|
|
const pollController = require("../controllers/pollController");
|
|
const meetingController = require("../controllers/meetingController");
|
|
const electionController = require("../controllers/electionController");
|
|
const feedBackController = require("../controllers/feedBackController");
|
|
const pdfController = require("../controllers/pdfController");
|
|
const shafafiatController = require("../controllers/shafafiatController");
|
|
|
|
/**
|
|
* @swagger
|
|
* /public/home:
|
|
* get:
|
|
* summary: Get home page data by user
|
|
* description: Fetches various sections of the home page including occasions, sliders, news, galleries, and notifications.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the content
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing home page data
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* occasion:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s1:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s2:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s3:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s4:
|
|
* type: object
|
|
* properties:
|
|
* nameTag:
|
|
* type: string
|
|
* news:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s5:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s6:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s1Side:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s2Side:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s3Side:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s4Side:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s5Side:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s6Side:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* s7Side:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* notificationsSide:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
// Home Swagger
|
|
router.get("/home", homeController.getHomeByUser);
|
|
|
|
router.get("/pdf", pdfController.GetAll);
|
|
// Shafafiat
|
|
router.get("/shafafiat", shafafiatController.getAll);
|
|
|
|
// Search Swagger
|
|
/**
|
|
* @swagger
|
|
* /public/search:
|
|
* get:
|
|
* summary: Search for news, galleries, and categories
|
|
* description: Searches for news articles, gallery items, and categories based on the provided search terms.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the content (optional)
|
|
* - in: query
|
|
* name: terms
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The search terms to filter the content
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing search results
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* news:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* media:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* pages:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/search", homeController.search);
|
|
// Year Banner Swagger
|
|
/**
|
|
* @swagger
|
|
* /public/year-banner:
|
|
* get:
|
|
* summary: Get year banner
|
|
* description: Fetches the year banner settings including social media links and display options.
|
|
* tags:
|
|
* - Public
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing year banner settings
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* mainCover:
|
|
* type: string
|
|
* description: The URL of the main cover image
|
|
* iranFlag:
|
|
* type: boolean
|
|
* description: Display Iran flag
|
|
* electionBtn:
|
|
* type: boolean
|
|
* description: Display election button
|
|
* hasEmail:
|
|
* type: boolean
|
|
* description: Display email option
|
|
* hasGPlus:
|
|
* type: boolean
|
|
* description: Display Google Plus option
|
|
* hasTweeter:
|
|
* type: boolean
|
|
* description: Display Twitter option
|
|
* hasInstagram:
|
|
* type: boolean
|
|
* description: Display Instagram option
|
|
* email:
|
|
* type: string
|
|
* description: Email address
|
|
* gPlus:
|
|
* type: string
|
|
* description: Google Plus URL
|
|
* tweeter:
|
|
* type: string
|
|
* description: Twitter URL
|
|
* instagram:
|
|
* type: string
|
|
* description: Instagram URL
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/yearBanner", yearBannerController.getYearBanner);
|
|
router.get("/books", pdfController.GetAll);
|
|
|
|
router.get("/books/:id", pdfController.GetOne);
|
|
|
|
// GetMenu Swagger
|
|
/**
|
|
* @swagger
|
|
* /public/menu:
|
|
* get:
|
|
* summary: Get menu items
|
|
* description: Fetches menu items including categories and static content pages for the specified portal.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the menu items (optional)
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing menu items
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* categories:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the category
|
|
* childs:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the sub-category
|
|
* navIndex:
|
|
* type: number
|
|
* description: The navigation index
|
|
* url:
|
|
* type: string
|
|
* description: The URL of the category
|
|
* modelType:
|
|
* type: string
|
|
* description: The portal type
|
|
* treeCat:
|
|
* type: object
|
|
* description: The tree structure of the category
|
|
* defaultPageType:
|
|
* type: string
|
|
* description: The default page type of the category
|
|
* staticContents:
|
|
* type: boolean
|
|
* description: Indicates whether static content pages are available in the menu
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/getMenu", categoryController.getMenu);
|
|
|
|
// Filter Data
|
|
router.post("/news/:length/:userViews", newsController.FilterNews);
|
|
|
|
router.get("/news/ostandar", newsController.OstandarNews);
|
|
|
|
// View News Swagger
|
|
/**
|
|
* @swagger
|
|
* /public/viewNews/{title}:
|
|
* get:
|
|
* summary: View news details
|
|
* description: Fetches the details of a specific news article by its title, including the creator and comments.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: title
|
|
* schema:
|
|
* type: string
|
|
* required: true
|
|
* description: The ID of the news article to view
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing the news article and its comments
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* news:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the news article
|
|
* title:
|
|
* type: string
|
|
* description: The title of the news article
|
|
* content:
|
|
* type: string
|
|
* description: The content of the news article
|
|
* userViews:
|
|
* type: number
|
|
* description: The number of user views
|
|
* _creator:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* description: The first name of the creator
|
|
* lastName:
|
|
* type: string
|
|
* description: The last name of the creator
|
|
* profilePic:
|
|
* type: string
|
|
* description: The profile picture URL of the creator
|
|
* catId:
|
|
* type: object
|
|
* properties:
|
|
* title:
|
|
* type: string
|
|
* description: The title of the category
|
|
* comments:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the comment
|
|
* content:
|
|
* type: string
|
|
* description: The content of the comment
|
|
* allowShow:
|
|
* type: boolean
|
|
* description: Whether the comment is allowed to be shown
|
|
* 404:
|
|
* description: News article not found
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/viewNews/:title", newsController.viewNews);
|
|
// Get News From DB Swagger
|
|
/**
|
|
* @swagger
|
|
* /public/getnews:
|
|
* get:
|
|
* summary: Get all news
|
|
* description: Fetches news articles based on various flags, categories, and other filters.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: flag
|
|
* schema:
|
|
* type: string
|
|
* enum: [category, all, new, slider, special, random, popular, events]
|
|
* description: Filter news by type
|
|
* - in: query
|
|
* name: catId
|
|
* schema:
|
|
* type: string
|
|
* description: The category ID to filter news by
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter news by
|
|
* - in: query
|
|
* name: limit
|
|
* schema:
|
|
* type: integer
|
|
* default: 10
|
|
* description: The number of news articles to return
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* default: 1
|
|
* description: The page number for pagination
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing paginated news articles
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the news article
|
|
* title:
|
|
* type: string
|
|
* description: The title of the news article
|
|
* summaryTitle:
|
|
* type: string
|
|
* description: The summary title of the news article
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the news article
|
|
* userViews:
|
|
* type: number
|
|
* description: The number of user views
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: The total number of news articles
|
|
* limit:
|
|
* type: integer
|
|
* description: The number of news articles per page
|
|
* totalPages:
|
|
* type: integer
|
|
* description: The total number of pages
|
|
* page:
|
|
* type: integer
|
|
* description: The current page number
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/getnews", newsController.getAllNews);
|
|
// GetCategory From title Swagger
|
|
/**
|
|
* @swagger
|
|
* /public/getCategory/{title}:
|
|
* get:
|
|
* summary: Get news by category
|
|
* description: Fetches news articles and related content for a specific category.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: title
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The title of the category
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* default: 1
|
|
* description: The page number for pagination
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing news and related content for the specified category
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* category:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the category
|
|
* title:
|
|
* type: string
|
|
* description: The title of the category
|
|
* heroNews:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the news article
|
|
* title:
|
|
* type: string
|
|
* description: The title of the news article
|
|
* news:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the news article
|
|
* title:
|
|
* type: string
|
|
* description: The title of the news article
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: The total number of news articles
|
|
* limit:
|
|
* type: integer
|
|
* description: The number of news articles per page
|
|
* totalPages:
|
|
* type: integer
|
|
* description: The total number of pages
|
|
* page:
|
|
* type: integer
|
|
* description: The current page number
|
|
* newsFile:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the news file
|
|
* title:
|
|
* type: string
|
|
* description: The title of the news file
|
|
* specials:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the special news article
|
|
* title:
|
|
* type: string
|
|
* description: The title of the special news article
|
|
* events:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the event news article
|
|
* title:
|
|
* type: string
|
|
* description: The title of the event news article
|
|
* polls:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the poll
|
|
* question:
|
|
* type: string
|
|
* description: The question of the poll
|
|
* latestNews:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the latest news article
|
|
* title:
|
|
* type: string
|
|
* description: The title of the latest news article
|
|
* 404:
|
|
* description: Category not found
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/getCategory/:title", newsController.getNewsByCategory);
|
|
// Get Realated News Swagger
|
|
/**
|
|
* @swagger
|
|
* /public/getRelatedNews:
|
|
* get:
|
|
* summary: Get related news articles
|
|
* description: Fetches news articles related to a specific news article based on its category.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the content
|
|
* - in: query
|
|
* name: title
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The ID of the target news article
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing related news articles
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the news article
|
|
* title:
|
|
* type: string
|
|
* description: The title of the news article
|
|
* summary:
|
|
* type: string
|
|
* description: The summary of the news article
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the news article
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID of the news article
|
|
* modelType:
|
|
* type: string
|
|
* description: The portal type of the news article
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/getRelatedNews", newsController.getRelated);
|
|
// Get Gallery Cat Swagger
|
|
/**
|
|
* @swagger
|
|
* /getGalleryCat/{catId}:
|
|
* get:
|
|
* summary: Get gallery items by category
|
|
* description: Fetches gallery items based on the specified category ID and gallery type.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: catId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The ID of the category to filter the gallery items
|
|
* - in: query
|
|
* name: type
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The type of gallery items to fetch (e.g., image, video)
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* default: 1
|
|
* description: The page number for pagination
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing gallery items and favorites
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* all:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the gallery item
|
|
* title:
|
|
* type: string
|
|
* description: The title of the gallery item
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the gallery item
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID of the gallery item
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the gallery item
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: The status of the gallery item
|
|
* _creator:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* lastName:
|
|
* type: string
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: The total number of gallery items
|
|
* limit:
|
|
* type: integer
|
|
* description: The number of items per page
|
|
* page:
|
|
* type: integer
|
|
* description: The current page number
|
|
* totalPages:
|
|
* type: integer
|
|
* description: The total number of pages
|
|
* pagingCounter:
|
|
* type: integer
|
|
* description: The paging counter
|
|
* hasPrevPage:
|
|
* type: boolean
|
|
* description: Whether there is a previous page
|
|
* hasNextPage:
|
|
* type: boolean
|
|
* description: Whether there is a next page
|
|
* prevPage:
|
|
* type: integer
|
|
* description: The previous page number
|
|
* nextPage:
|
|
* type: integer
|
|
* description: The next page number
|
|
* favorites:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the favorite gallery item
|
|
* title:
|
|
* type: string
|
|
* description: The title of the favorite gallery item
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the favorite gallery item
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID of the favorite gallery item
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the favorite gallery item
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: The status of the favorite gallery item
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/getGalleryCat/:catId", galleryController.getGalleryPublic);
|
|
|
|
router.get("/gallery/archive", galleryController.GetArchive);
|
|
|
|
// Get All Gallery Swagger
|
|
/**
|
|
* @swagger
|
|
* /public/getAllGallery:
|
|
* get:
|
|
* summary: Get all gallery items
|
|
* description: Fetches all gallery items based on type, page, and portal.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: type
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The type of gallery items to fetch (e.g., image, video)
|
|
* - in: query
|
|
* name: page
|
|
* schema:
|
|
* type: integer
|
|
* default: 1
|
|
* description: The page number for pagination
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the content
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing gallery items, hero item, and favorites
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* all:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the gallery item
|
|
* title:
|
|
* type: string
|
|
* description: The title of the gallery item
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the gallery item
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID of the gallery item
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the gallery item
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: The status of the gallery item
|
|
* _creator:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* lastName:
|
|
* type: string
|
|
* totalDocs:
|
|
* type: integer
|
|
* description: The total number of gallery items
|
|
* limit:
|
|
* type: integer
|
|
* description: The number of items per page
|
|
* page:
|
|
* type: integer
|
|
* description: The current page number
|
|
* totalPages:
|
|
* type: integer
|
|
* description: The total number of pages
|
|
* pagingCounter:
|
|
* type: integer
|
|
* description: The paging counter
|
|
* hasPrevPage:
|
|
* type: boolean
|
|
* description: Whether there is a previous page
|
|
* hasNextPage:
|
|
* type: boolean
|
|
* description: Whether there is a next page
|
|
* prevPage:
|
|
* type: integer
|
|
* description: The previous page number
|
|
* nextPage:
|
|
* type: integer
|
|
* description: The next page number
|
|
* hero:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the hero gallery item
|
|
* title:
|
|
* type: string
|
|
* description: The title of the hero gallery item
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the hero gallery item
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID of the hero gallery item
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the hero gallery item
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: The status of the hero gallery item
|
|
* favorites:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the favorite gallery item
|
|
* title:
|
|
* type: string
|
|
* description: The title of the favorite gallery item
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the favorite gallery item
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID of the favorite gallery item
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the favorite gallery item
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: The status of the favorite gallery item
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/getAllGallery", galleryController.getAllGallery);
|
|
// Get Gallery Title
|
|
/**
|
|
* @swagger
|
|
* /public/getGallery/{title}:
|
|
* get:
|
|
* summary: View a gallery item
|
|
* description: Fetches a single gallery item by its title.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: title
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The title (ID) of the gallery item to fetch
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing the gallery item details
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the gallery item
|
|
* title:
|
|
* type: string
|
|
* description: The title of the gallery item
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the gallery item
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID of the gallery item
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the gallery item
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: The status of the gallery item
|
|
* _creator:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* lastName:
|
|
* type: string
|
|
* profilePic:
|
|
* type: string
|
|
* description: The URL of the creator's profile picture
|
|
* userViews:
|
|
* type: integer
|
|
* description: The number of user views for the gallery item
|
|
* 404:
|
|
* description: Gallery item not found
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/getGallery/:title", galleryController.viewGallery);
|
|
// Get Related Gallery
|
|
/**
|
|
* @swagger
|
|
* /public/getRelatedGallery:
|
|
* get:
|
|
* summary: Get related gallery items
|
|
* description: Fetches related gallery items based on the provided type and excludes the current gallery item.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: type
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The type of gallery items to fetch
|
|
* - in: query
|
|
* name: title
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The title (ID) of the current gallery item to exclude from the results
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON array of related gallery items
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the gallery item
|
|
* title:
|
|
* type: string
|
|
* description: The title of the gallery item
|
|
* customDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The custom date of the gallery item
|
|
* catId:
|
|
* type: string
|
|
* description: The category ID of the gallery item
|
|
* galleryType:
|
|
* type: string
|
|
* description: The type of the gallery item
|
|
* galleryStatus:
|
|
* type: boolean
|
|
* description: The status of the gallery item
|
|
* _creator:
|
|
* type: object
|
|
* properties:
|
|
* firstName:
|
|
* type: string
|
|
* lastName:
|
|
* type: string
|
|
* userViews:
|
|
* type: integer
|
|
* description: The number of user views for the gallery item
|
|
* 500:
|
|
* description: Internal server error
|
|
*/
|
|
router.get("/getRelatedGallery", galleryController.getRelated);
|
|
// router.get('/getFooter', contentController.footer);
|
|
// View Contents
|
|
/**
|
|
* @swagger
|
|
* /public/viewContent/{param}:
|
|
* get:
|
|
* summary: View content by parameter
|
|
* description: Retrieves content based on the provided parameter.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: param
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The parameter used to identify the content.
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing the content.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the content.
|
|
* title:
|
|
* type: string
|
|
* description: The title of the content.
|
|
* description:
|
|
* type: string
|
|
* description: The description of the content.
|
|
* param:
|
|
* type: string
|
|
* description: The parameter used to identify the content.
|
|
* content:
|
|
* type: string
|
|
* description: The actual content.
|
|
* createdAt:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The date and time when the content was created.
|
|
* 404:
|
|
* description: Content not found.
|
|
* 500:
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/viewContent/:param", contentController.viewContent);
|
|
// Add Comment
|
|
/**
|
|
* @swagger
|
|
* /public/addComment:
|
|
* post:
|
|
* summary: Add a comment
|
|
* description: Adds a comment to a news article, category, or contact form.
|
|
* tags:
|
|
* - Public
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description:
|
|
* type: string
|
|
* email:
|
|
* type: string
|
|
* modelId:
|
|
* type: string
|
|
* modelName:
|
|
* type: string
|
|
* captcha:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: A JSON object containing the added comment.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* 422:
|
|
* description: Validation error. The request body contains invalid data.
|
|
* 403:
|
|
* description: Forbidden. The user is not allowed to add a comment to the specified model.
|
|
* 404:
|
|
* description: Not found. The specified model does not exist.
|
|
* 500:
|
|
* description: Internal server error.
|
|
*/
|
|
router.post("/addComment", commentController.addComment);
|
|
// Get Comments Id
|
|
/**
|
|
* @swagger
|
|
* /public/getComments/{id}:
|
|
* get:
|
|
* summary: Get comments by model ID
|
|
* description: Retrieves comments associated with a specific model ID.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: id
|
|
* required: true
|
|
* description: The ID of the model.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: An array of comments associated with the specified model ID.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Comment'
|
|
* 500:
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/getComments/:id", commentController.getCommentById);
|
|
// Get News Files
|
|
/**
|
|
* @swagger
|
|
* /public/getNewsFile:
|
|
* get:
|
|
* summary: Get news files
|
|
* description: Retrieves news files based on the provided query parameters.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the news files.
|
|
* - in: query
|
|
* name: limit
|
|
* schema:
|
|
* type: integer
|
|
* default: 4
|
|
* description: The maximum number of news files to retrieve. Defaults to 4 if not provided.
|
|
* - in: query
|
|
* name: skip
|
|
* schema:
|
|
* type: integer
|
|
* default: 0
|
|
* description: The number of news files to skip. Defaults to 0 if not provided.
|
|
* responses:
|
|
* '200':
|
|
* description: An array of news files.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/getNewsFile", newsFileController.getAllNewsFile);
|
|
|
|
// Get News File Title
|
|
/**
|
|
* @swagger
|
|
* /public/getNewsFile/{title}:
|
|
* get:
|
|
* summary: View news file by title
|
|
* description: Retrieves a specific news file along with related news articles.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: title
|
|
* required: true
|
|
* description: The title of the news file.
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* '200':
|
|
* description: A news file and related news articles.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* newsFile:
|
|
* $ref: '#/components/schemas/NewsFile'
|
|
* news:
|
|
* type: object
|
|
* properties:
|
|
* docs:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/News'
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/getNewsFile/:title", newsFileController.viewNewsFile);
|
|
// Get Links
|
|
/**
|
|
* @swagger
|
|
* /public/getLinks:
|
|
* get:
|
|
* summary: Get all links
|
|
* description: Retrieves all links based on the provided query parameters.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the links. If not provided, defaults to 'ostandari'.
|
|
* responses:
|
|
* '200':
|
|
* description: An array of links.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Link'
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/getLinks", linksController.getAllLinks);
|
|
// Get Sliders
|
|
/**
|
|
* @swagger
|
|
* /public/getSliders:
|
|
* get:
|
|
* summary: Get all sliders by user
|
|
* description: Retrieves all sliders based on the provided query parameters.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the sliders. If not provided, defaults to 'ostandari'.
|
|
* responses:
|
|
* '200':
|
|
* description: An array of sliders.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Slider'
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/getSliders", sliderController.getAllSliderByUser);
|
|
|
|
// Get Sections
|
|
/**
|
|
* @swagger
|
|
* /public/getSections:
|
|
* get:
|
|
* summary: Get sections
|
|
* description: Retrieves sections based on the provided portal type.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: query
|
|
* name: portal
|
|
* schema:
|
|
* type: string
|
|
* description: The portal type to filter the sections.
|
|
* responses:
|
|
* '200':
|
|
* description: Sections retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* sectionOne:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Section'
|
|
* sectionTwo:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Section'
|
|
* sectionThree:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/Section'
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/getSections", newsController.getSections);
|
|
// Search News bytitle
|
|
/**
|
|
* @swagger
|
|
* /public/searchnewsbytitle/{title}:
|
|
* get:
|
|
* summary: Search news by title
|
|
* description: Retrieves news based on the provided title search term.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: title
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* description: The title search term.
|
|
* responses:
|
|
* '200':
|
|
* description: News retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: array
|
|
* items:
|
|
* $ref: '#/components/schemas/News'
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/searchnewsbytitle/:title", newsController.searchForSlider);
|
|
|
|
// Counter Day
|
|
/**
|
|
* @swagger
|
|
* /public/counterDay:
|
|
* get:
|
|
* summary: Get counter day by user
|
|
* description: Retrieves the counter day information for the current user.
|
|
* tags:
|
|
* - Public
|
|
* responses:
|
|
* '200':
|
|
* description: Counter day information retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* $ref: '#/components/schemas/CounterDay'
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/counterDay", counterDayController.getCounterDayByUser);
|
|
// Get Captcha
|
|
/**
|
|
* @swagger
|
|
* /public/getCaptcha:
|
|
* get:
|
|
* summary: Get CAPTCHA
|
|
* description: Retrieves a CAPTCHA image for verification purposes.
|
|
* tags:
|
|
* - Public
|
|
* responses:
|
|
* '200':
|
|
* description: CAPTCHA image retrieved successfully.
|
|
* content:
|
|
* image/svg+xml:
|
|
* schema:
|
|
* type: string
|
|
* format: binary
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/getCaptcha", captchaController.getCaptcha);
|
|
// Add Answer
|
|
/**
|
|
* @swagger
|
|
* /public/answer:
|
|
* post:
|
|
* summary: Submit answers to a survey
|
|
* description: Submit user answers to a survey.
|
|
* tags:
|
|
* - Public
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* surveyId:
|
|
* type: string
|
|
* description: The ID of the survey.
|
|
* option:
|
|
* type: array
|
|
* items:
|
|
* type: string
|
|
* description: An array of selected options.
|
|
* pollToken:
|
|
* type: string
|
|
* description: Token for the survey.
|
|
* responses:
|
|
* '200':
|
|
* description: Survey response submitted successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Confirmation message.
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.post("/answer", pollController.answer);
|
|
// Meet Ostandari
|
|
/**
|
|
* @swagger
|
|
* /public/meetingOstandar:
|
|
* post:
|
|
* summary: Add a meeting request
|
|
* description: Submit a meeting request to Ostandar.
|
|
* tags:
|
|
* - Public
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description: The name of the person requesting the meeting.
|
|
* subject:
|
|
* type: string
|
|
* description: The subject of the meeting.
|
|
* description:
|
|
* type: string
|
|
* description: The description of the meeting.
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* description: The email of the person requesting the meeting (optional).
|
|
* phoneNumber:
|
|
* type: string
|
|
* description: The phone number of the person requesting the meeting.
|
|
* nationalCode:
|
|
* type: string
|
|
* description: The national code of the person requesting the meeting.
|
|
* captcha:
|
|
* type: string
|
|
* description: The captcha code for verification.
|
|
* responses:
|
|
* '200':
|
|
* description: Meeting request submitted successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description: The name of the person requesting the meeting.
|
|
* subject:
|
|
* type: string
|
|
* description: The subject of the meeting.
|
|
* description:
|
|
* type: string
|
|
* description: The description of the meeting.
|
|
* phoneNumber:
|
|
* type: string
|
|
* description: The phone number of the person requesting the meeting.
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* description: The email of the person requesting the meeting.
|
|
* nationalCode:
|
|
* type: string
|
|
* description: The national code of the person requesting the meeting.
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.post("/meetingOstandar", meetingController.addMeeting);
|
|
// Add FeedBack
|
|
/**
|
|
* @swagger
|
|
* /public/addFeedBack:
|
|
* post:
|
|
* summary: Add feedback
|
|
* description: Submit feedback from users.
|
|
* tags:
|
|
* - Public
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* name:
|
|
* type: string
|
|
* description: The name of the person providing the feedback.
|
|
* description:
|
|
* type: string
|
|
* description: The feedback description.
|
|
* email:
|
|
* type: string
|
|
* format: email
|
|
* description: The email of the person providing the feedback (optional).
|
|
* phoneNumber:
|
|
* type: string
|
|
* description: The phone number of the person providing the feedback.
|
|
* captcha:
|
|
* type: string
|
|
* description: The captcha code for verification.
|
|
* responses:
|
|
* '200':
|
|
* description: Feedback submitted successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: A success message indicating the feedback was saved.
|
|
* '422':
|
|
* description: Validation error. Indicates missing or invalid fields in the request body.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* validation:
|
|
* type: object
|
|
* description: Object containing details about the validation errors.
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.post("/addFeedBack", feedBackController.addFeedBack);
|
|
|
|
////////////// election
|
|
// Get Electronic
|
|
/**
|
|
* @swagger
|
|
* /public/getElection:
|
|
* get:
|
|
* summary: Get election by user
|
|
* description: Retrieves the election information for the logged-in user.
|
|
* tags:
|
|
* - Public
|
|
* security:
|
|
* - bearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Election information retrieved successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the election.
|
|
* title:
|
|
* type: string
|
|
* description: The title of the election.
|
|
* description:
|
|
* type: string
|
|
* description: The description of the election.
|
|
* startDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The start date of the election.
|
|
* endDate:
|
|
* type: string
|
|
* format: date-time
|
|
* description: The end date of the election.
|
|
* voters:
|
|
* type: array
|
|
* description: List of voters.
|
|
* items:
|
|
* type: object
|
|
* properties:
|
|
* _id:
|
|
* type: string
|
|
* description: The ID of the voter.
|
|
* voted:
|
|
* type: boolean
|
|
* description: Indicates whether the voter has already voted.
|
|
* '403':
|
|
* description: Access forbidden. Indicates that the user does not have permission to view the election.
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/getElection", isVoter, electionController.getElectionByUser);
|
|
// Add Vote
|
|
/**
|
|
* @swagger
|
|
* /public/addVote:
|
|
* post:
|
|
* summary: Add vote
|
|
* description: Allows a logged-in user to cast a vote in an election.
|
|
* tags:
|
|
* - Public
|
|
* security:
|
|
* - bearerAuth: []
|
|
* requestBody:
|
|
* required: true
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* electionId:
|
|
* type: string
|
|
* description: The ID of the election.
|
|
* candidateId:
|
|
* type: string
|
|
* description: The ID of the candidate.
|
|
* responses:
|
|
* '200':
|
|
* description: Vote added successfully.
|
|
* content:
|
|
* application/json:
|
|
* schema:
|
|
* type: object
|
|
* properties:
|
|
* message:
|
|
* type: string
|
|
* description: Success message indicating the vote was added successfully.
|
|
* '403':
|
|
* description: Access forbidden. Indicates that the user does not have permission to vote.
|
|
* '404':
|
|
* description: Not found. Indicates that the specified election or candidate does not exist.
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.post("/addVote", isVoter, electionController.addVote);
|
|
|
|
///////////// backup
|
|
/**
|
|
* @swagger
|
|
* /public/backup/{token}:
|
|
* get:
|
|
* summary: Create backup
|
|
* description: Allows authorized users with specific permissions to create a backup of the database.
|
|
* tags:
|
|
* - Public
|
|
* parameters:
|
|
* - in: path
|
|
* name: token
|
|
* required: true
|
|
* description: User token for authorization. Add 'Bearer ' before the token.
|
|
* schema:
|
|
* type: string
|
|
* security:
|
|
* - BearerAuth: []
|
|
* responses:
|
|
* '200':
|
|
* description: Backup created successfully.
|
|
* content:
|
|
* application/zip:
|
|
* schema:
|
|
* type: string
|
|
* format: binary
|
|
* '401':
|
|
* description: Unauthorized. Indicates that the user is not authorized to create a backup.
|
|
* '500':
|
|
* description: Internal server error.
|
|
*/
|
|
router.get("/backup/:token", dataBackupController.createBackUp);
|
|
|
|
//////////// add all news imported
|
|
// router.post('/addAllNews', newsController.addAllNews)
|
|
// router.get('/deleted', newsController.deleteAllNews)
|
|
|
|
module.exports = router;
|