Commit 2c0524e1 authored by KangMin An's avatar KangMin An
Browse files

Update : 지역 코드 외부 요청 인가.

parent 19b7c6c2
......@@ -23,6 +23,7 @@
"@babel/preset-env": "^7.11.5",
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"helmet": "^4.1.1",
......
import cookieParser from "cookie-parser";
import cors from "cors";
import express from "express";
import morgan from "morgan";
import helmet from "helmet";
......@@ -17,6 +18,7 @@ const app = express();
app.set("view engine", "pug");
app.set("views", path.join(__dirname, "views"));
app.use(cors());
app.use(helmet());
app.use(cookieParser());
app.use(express.json());
......
......@@ -89,8 +89,45 @@ export const getUserWeatherData = (req, res) => {
};
// 지역 코드 요청 처리
export const getLocCode = (req, res) => {
export const getLocCode = async (req, res) => {
/* 통합 지역 코드 및 이름 json으로 생성 및 전송 */
let locCodes = [];
res.status(statusCode.ok).send(serverMSG.server_ok);
const does = await db.Doe.findAll({ logging: false });
const sggs = await db.Sgg.findAll({ logging: false });
const emds = await db.Emd.findAll({ logging: false });
let doe_sgg = [];
let sgg_emd = [];
does.map((info_doe) => {
let temp = {
name_doe: info_doe["name_doe"],
code_doe: info_doe["code_doe"],
};
temp.sgg = sggs.filter(
(info_sgg) => info_sgg["code_doe"] === info_doe["code_doe"]
);
doe_sgg.push(temp);
});
sggs.map((info_sgg) => {
let temp = {
code_doe: info_sgg["code_doe"],
name_sgg: info_sgg["name_sgg"],
code_sgg: info_sgg["code_sgg"],
};
temp.emd = emds.filter(
(info_emd) => info_emd["code_sgg"] === info_sgg["code_sgg"]
);
sgg_emd.push(temp);
});
res.status(statusCode.ok).json({
locCodes: {
DOE: does,
SGG: doe_sgg,
EMD: sgg_emd,
},
});
};
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