From f14de9eea4c9583f0d7c4954b5cf38c2812595b9 Mon Sep 17 00:00:00 2001 From: glen Date: Wed, 3 Nov 2021 12:19:48 +0900 Subject: [PATCH 1/2] Delete feat/swagger --- server/app.js | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/server/app.js b/server/app.js index 0e2de3c6..9a7dc050 100644 --- a/server/app.js +++ b/server/app.js @@ -3,8 +3,6 @@ import "express-async-errors"; import cors from "cors"; import cookieParser from "cookie-parser"; import morgan from "morgan"; -import swaggerUi from "swagger-ui-express"; -import swaggerJSDoc from "swagger-jsdoc"; import authRouter from "./router/auth.js"; import docRouter from "./router/doc.js"; import rankRouter from "./router/rank.js"; @@ -24,41 +22,13 @@ const corsOptions = { allowedHeaders: ["Content-type", "Authorization"], credentials: true, }; -const swaggerDefinition = { - info: { - title: "Winner's Record API", - version: "1.0.0", - description: "API description", - }, - host: "locahost:8080", - basePath: "/", - securityDefinitions: { - bearerAuth: { - type: "apiKey", - name: "Authorization", - scheme: "bearer", - in: "header", - }, - }, -}; -const options = { - swaggerDefinition, - apis: ["./router/*.js"], -}; - -const swaggerSpec = swaggerJSDoc(options); -app.get("/swagger.json", (req, res) => { - res.setHeader("Content-Type", "application/json"); - res.send(swaggerSpec); -}); app.use(express.json()); app.use(cors(corsOptions)); app.use(cookieParser()); app.use(morgan("tiny")); -app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec)); -app.use("/wr", (req, res, next) => { +app.get("/wr", (req, res, next) => { res.send(`Winner's Record`); }); From 8f71d39aa71d225d2540f6107c65d9b047cddb2d Mon Sep 17 00:00:00 2001 From: glen Date: Wed, 3 Nov 2021 15:03:14 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=20fix/total=20-=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/data/doc.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server/data/doc.js b/server/data/doc.js index 7ef4e8d1..5e0bcdd5 100644 --- a/server/data/doc.js +++ b/server/data/doc.js @@ -168,10 +168,11 @@ export async function validType(type) { export async function editDoc(docId, data) { const img = data.img; //[string, string] - await db.Docs_Images.destroy({ - where: { docId }, - }); - if (!img.length) { + + if (Array.isArray(img) && !img.length) { + await db.Docs_Images.destroy({ + where: { docId }, + }); if (data.event === "tennis") { await db.Docs_Images.create({ docId, @@ -193,7 +194,10 @@ export async function editDoc(docId, data) { imgId: 58, }); } - } else { + } else if (Array.isArray(img)) { + await db.Docs_Images.destroy({ + where: { docId }, + }); for (let i = 0; i < img.length; i++) { const newImg = await db.Images.create({ link: img[i], @@ -229,7 +233,6 @@ export async function editDoc(docId, data) { const editedDoc = await db.Docs.findOne({ where: { id: docId }, }).catch((err) => console.log(err)); - return editedDoc; }