Added poll create route in backend✔️

This commit is contained in:
Manik Maity
2024-11-08 20:27:06 +05:30
parent 9f689beb9d
commit 10425305dd
9 changed files with 237 additions and 16 deletions

View File

@@ -0,0 +1,63 @@
import express from "express";
import { verifyToken } from "../../middlwares/verifyToken.js";
import { createPollController } from "../../controllers/poll.controller.js";
import pollDataSchema from "../../validations/pollDataValidation.js";
import validator from "../../validations/validator.js";
const pollRouter = express.Router();
/**
* @swagger
* /poll/test:
* get:
* summary: Test route for poll
* tags: [Poll]
* responses:
* 200:
* description: Success
*/
pollRouter.get("/test", (req, res) => {
res.json({
success : true,
message : "Poll route is working✔"
})
})
/**
* @swagger
* /poll/create:
* post:
* summary: Create poll
* tags: [Poll]
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* title:
* type: string
* description:
* type: string
* options:
* type: array
* items:
* type: string
* required:
* - title
* - description
* - options
* responses:
* 201:
* description: Poll created successfully
* 400:
* description: Validation error
* 401:
* description: Unauthorized
* 500:
* description: Internal server error
*
*/
pollRouter.post("/create", validator(pollDataSchema), verifyToken, createPollController);
export default pollRouter;