Commit 117bbc7e authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

0720

parent 69a26550
...@@ -17,7 +17,6 @@ export const ansSurvey = async (surveyId: string) => { ...@@ -17,7 +17,6 @@ export const ansSurvey = async (surveyId: string) => {
return data; return data;
} }
//동혁
export const getSurveys = async () => { export const getSurveys = async () => {
const { data } = await axios.get(`${baseUrl}/surveys/`); const { data } = await axios.get(`${baseUrl}/surveys/`);
return data; return data;
......
import { NextFunction, Request, Response } from "express"; import { NextFunction, Request, Response } from "express";
import { surveyDb } from "../db"; import { surveyDb } from "../db";
import { asyncWrap } from "../helpers/asyncWrap"; import { asyncWrap } from "../helpers/asyncWrap";
// import jwt, { JwtPayload } from "jsonwebtoken";
// import { cookieConfig, envConfig, jwtCofig } from "../config";
export interface TypedRequestAuth<T> extends Request { export interface TypedRequestAuth<T> extends Request {
auth: T; auth: T;
...@@ -26,7 +28,6 @@ export const getSurveyById = asyncWrap(async (req, res) => { ...@@ -26,7 +28,6 @@ export const getSurveyById = asyncWrap(async (req, res) => {
return res.json(survey); return res.json(survey);
}); });
//동혁
export const getSurveys = asyncWrap(async (reqExp: Request, res: Response) => { export const getSurveys = asyncWrap(async (reqExp: Request, res: Response) => {
const req = reqExp as TypedRequestAuth<{ userId: string }>; const req = reqExp as TypedRequestAuth<{ userId: string }>;
const { userId } = req.auth; const { userId } = req.auth;
...@@ -69,3 +70,29 @@ export const userBySurveyId = async ( ...@@ -69,3 +70,29 @@ export const userBySurveyId = async (
); );
} }
}; };
// export const checksurvey = asyncWrap(async(req, res)=> {
// const {_id} = req.body
// const surveyExist = await surveyDb.isSurvey(_id);
// if (surveyExist) {
// return res.status(422).send("이미 제출된 설문조사입니다")
// }
// });
// export const surveynotexist = asyncWrap(async (req, res) => {
// const { _id } = req.body;
// console.log(`surveyId: ${_id}`);
// const checksurveyId = await surveyDb.findUserBySurveyId(_id);
// const surveytoken = jwt.sign({existsurveyId: checksurveyId?.id}, jwtCofig.secret, {
// expiresIn:jwtCofig.expires,
// });
// res.cookie(cookieConfig.name, surveytoken, {
// maxAge:cookieConfig.maxAge,
// path:"/",
// httpOnly: envConfig.mode === "production",
// secure: envConfig.mode === "production",
// })
// res.json({
// surveyId: checksurveyId?._id
// })
// });
\ No newline at end of file
...@@ -36,3 +36,12 @@ export const deleteSurvey = async (surveyId: string) => { ...@@ -36,3 +36,12 @@ export const deleteSurvey = async (surveyId: string) => {
const survey = await Survey.findOneAndDelete({ _id: surveyId }); const survey = await Survey.findOneAndDelete({ _id: surveyId });
return survey; return survey;
}; };
// export const isSurvey = async (surveyId: string) =>{
// const survey = await Survey.findOne({surveyId});
// if (survey) {
// return true;
// } else {
// return false;
// }
// }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment