From 0b259284717d1b2634a0cce563647f3d15eb87f9 Mon Sep 17 00:00:00 2001 From: daesung Date: Sat, 28 Sep 2024 17:48:03 +0900 Subject: [PATCH 01/27] =?UTF-8?q?=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8=20?= =?UTF-8?q?=EC=84=B8=ED=8C=85=20&=20=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=9F=AC?= =?UTF-8?q?=EB=A6=AC=20=EC=84=A4=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/userController.js | 43 +- index.js | 35 +- middlewares/auth.js | 0 package-lock.json | 888 ++++++++++++++++++++++++++++++++++- package.json | 6 +- routes/indexRouter.js | 9 + routes/userRouter.js | 3 + schema/user.js | 3 + 8 files changed, 971 insertions(+), 16 deletions(-) create mode 100644 middlewares/auth.js create mode 100644 routes/indexRouter.js diff --git a/controller/userController.js b/controller/userController.js index 3e57522..38eadd2 100644 --- a/controller/userController.js +++ b/controller/userController.js @@ -1,5 +1,44 @@ +const User = require("../schema/user"); // User 모델 가져오기 const bcrypt = require("bcrypt"); +const jwt = require("jsonwebtoken"); exports.login = async(req, res, next) => { - -} \ No newline at end of file + +} + +exports.signup = async (req, res, next) => { + const { username, password } = req.body; + + try { + // 1. 사용자 중복 검사 + const existingUser = await User.findOne({ username }); + if (existingUser) { + return res.status(400).json({ message: "Username already exists" }); + } + + // 2. 비밀번호 해싱 + const hashedPassword = await bcrypt.hash(password, 10); + + // 3. 새로운 사용자 생성 및 저장 + const newUser = new User({ + username, + password: hashedPassword + }); + + await newUser.save(); + + // 4. JWT 토큰 발급 + const token = jwt.sign( + { userId: newUser._id, username: newUser.username }, + "your_jwt_secret", // 비밀키 (환경 변수로 관리) + { expiresIn: "1h" } // 토큰 유효 기간 설정 + ); + + // 5. 응답으로 토큰 반환 + return res.status(201).json({ token }); + + } catch (error) { + console.error(error); + res.status(500).json({ message: "Server error" }); + } +}; \ No newline at end of file diff --git a/index.js b/index.js index 8b4b44c..f04cb58 100644 --- a/index.js +++ b/index.js @@ -1,20 +1,31 @@ -const express = require("express") -const app = express() -// router import +const express = require("express"); +const mongoose = require("mongoose"); +const app = express(); +require('dotenv').config(); + +// 미들웨어 설정 app.use(express.json()); -app.use(cors()); -// MongoDB 연결 -mongoose.connect('mongodb://127.0.0.1:27017/youtube', { +// MongoDB 연결 (.env 파일에서 MongoDB URI 가져오기) +mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true, +}).then(() => { + console.log('MongoDB connected'); +}).catch((err) => { + console.error('MongoDB connection error:', err); }); -// use router -app.use() +// 라우터 사용 +const indexRouter = require("./routes/indexRouter"); +const userRouter = require('./routes/userRouter'); + +app.use("/", indexRouter); +app.use("/user", userRouter); // 예: /user 경로에서 userRouter 사용 -app.listen(3000, () => { - console.log("server on in http://localhost:3000"); - -}) \ No newline at end of file +// 서버 시작 +const PORT = process.env.PORT || 3000; +app.listen(PORT, () => { + console.log(`Server running on http://localhost:${PORT}`); +}); \ No newline at end of file diff --git a/middlewares/auth.js b/middlewares/auth.js new file mode 100644 index 0000000..e69de29 diff --git a/package-lock.json b/package-lock.json index 12adb26..eb988b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,59 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "bcrypt": "^5.1.1", + "dotenv": "^16.4.5", "express": "^4.21.0", - "install": "^0.13.0" + "install": "^0.13.0", + "jsonwebtoken": "^9.0.2", + "mongoose": "^8.7.0" } }, + "node_modules/@mapbox/node-pre-gyp": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", + "integrity": "sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==", + "dependencies": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + } + }, + "node_modules/@mongodb-js/saslprep": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.9.tgz", + "integrity": "sha512-tVkljjeEaAhCqTzajSdgbQ6gE6f3oneVwa3iXR6csiEwXXOFsiC6Uh9iAjAhXPtqa/XMDHWjjeNH/77m/Yq2dw==", + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", + "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==" + }, + "node_modules/@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -26,12 +75,88 @@ "node": ">= 0.6" } }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/agent-base/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/agent-base/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" + }, + "node_modules/are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "deprecated": "This package is no longer supported.", + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", "license": "MIT" }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/bcrypt": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz", + "integrity": "sha512-AGBHOG5hPYZ5Xl9KXzU5iKq9516yEmvCKDg3ecP5kX2aB6UqTeXZxk2ELnDgDm6BQSMlLt9rDB4LoSMx0rYwww==", + "hasInstallScript": true, + "dependencies": { + "@mapbox/node-pre-gyp": "^1.0.11", + "node-addon-api": "^5.0.0" + }, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/body-parser": { "version": "1.20.3", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", @@ -56,6 +181,28 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/bson": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.8.0.tgz", + "integrity": "sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ==", + "engines": { + "node": ">=16.20.1" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -84,6 +231,32 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "engines": { + "node": ">=10" + } + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "bin": { + "color-support": "bin.js" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -146,6 +319,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==" + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -165,12 +343,44 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-libc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "license": "MIT" }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, "node_modules/encodeurl": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", @@ -294,6 +504,33 @@ "node": ">= 0.6" } }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -303,6 +540,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/gauge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", + "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "deprecated": "This package is no longer supported.", + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", + "signal-exit": "^3.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.2" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/get-intrinsic": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", @@ -322,6 +579,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -370,6 +647,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -398,6 +680,39 @@ "node": ">= 0.8" } }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/https-proxy-agent/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/https-proxy-agent/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -410,6 +725,16 @@ "node": ">=0.10.0" } }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -434,6 +759,124 @@ "node": ">= 0.10" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jsonwebtoken/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/kareem": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.6.3.tgz", + "integrity": "sha512-C3iHfuGUXK2u8/ipq9LfjFfXFxAZMQJJq7vLS45r3D9Y2xQ/m4S8zaR4zMLFWh9AsNPXmcFfUDhTEO8UIC/V6Q==", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -443,6 +886,11 @@ "node": ">= 0.6" } }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==" + }, "node_modules/merge-descriptors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", @@ -494,6 +942,179 @@ "node": ">= 0.6" } }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mongodb": { + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.9.0.tgz", + "integrity": "sha512-UMopBVx1LmEUbW/QE0Hw18u583PEDVQmUmVzzBRH0o/xtE9DBRA5ZYLOjpLIa03i8FXjzvQECJcqoMvCXftTUA==", + "dependencies": { + "@mongodb-js/saslprep": "^1.1.5", + "bson": "^6.7.0", + "mongodb-connection-string-url": "^3.0.0" + }, + "engines": { + "node": ">=16.20.1" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.188.0", + "@mongodb-js/zstd": "^1.1.0", + "gcp-metadata": "^5.2.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=6.0.0 <7", + "snappy": "^7.2.2", + "socks": "^2.7.1" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.1.tgz", + "integrity": "sha512-XqMGwRX0Lgn05TDB4PyG2h2kKO/FfWJyCzYQbIhXUxz7ETt0I/FqHjUeqj37irJ+Dl1ZtU82uYyj14u2XsZKfg==", + "dependencies": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^13.0.0" + } + }, + "node_modules/mongoose": { + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.7.0.tgz", + "integrity": "sha512-rUCSF1mMYQXjXYdqEQLLlMD3xbcj2j1/hRn+9VnVj7ipzru/UoUZxlj/hWmteKMAh4EFnDZ+BIrmma9l/0Hi1g==", + "dependencies": { + "bson": "^6.7.0", + "kareem": "2.6.3", + "mongodb": "6.9.0", + "mpath": "0.9.0", + "mquery": "5.0.0", + "ms": "2.1.3", + "sift": "17.1.3" + }, + "engines": { + "node": ">=16.20.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" + } + }, + "node_modules/mongoose/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mquery": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", + "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", + "dependencies": { + "debug": "4.x" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/mquery/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mquery/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -509,6 +1130,83 @@ "node": ">= 0.6" } }, + "node_modules/node-addon-api": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", + "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-fetch/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/node-fetch/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/node-fetch/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/npmlog": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "deprecated": "This package is no longer supported.", + "dependencies": { + "are-we-there-yet": "^2.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object-inspect": { "version": "1.13.2", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", @@ -533,6 +1231,14 @@ "node": ">= 0.8" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -542,6 +1248,14 @@ "node": ">= 0.8" } }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/path-to-regexp": { "version": "0.1.10", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", @@ -561,6 +1275,14 @@ "node": ">= 0.10" } }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", @@ -600,6 +1322,34 @@ "node": ">= 0.8" } }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -626,6 +1376,17 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "license": "MIT" }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/send": { "version": "0.19.0", "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", @@ -680,6 +1441,11 @@ "node": ">= 0.8.0" } }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -721,6 +1487,24 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/sift": { + "version": "17.1.3", + "resolved": "https://registry.npmjs.org/sift/-/sift-17.1.3.tgz", + "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==" + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -730,6 +1514,54 @@ "node": ">= 0.8" } }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -739,6 +1571,17 @@ "node": ">=0.6" } }, + "node_modules/tr46": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", + "integrity": "sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==", + "dependencies": { + "punycode": "^2.3.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -761,6 +1604,11 @@ "node": ">= 0.8" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -778,6 +1626,44 @@ "engines": { "node": ">= 0.8" } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-9WWbymnqj57+XEuqADHrCJ2eSXzn8WXIW/YSGaZtb2WKAInQ6CHfaUUcTyyver0p8BDg5StLQq8h1vtZuwmOig==", + "dependencies": { + "tr46": "^4.1.1", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" } } } diff --git a/package.json b/package.json index 5d55f60..58ae97b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,11 @@ "license": "ISC", "description": "", "dependencies": { + "bcrypt": "^5.1.1", + "dotenv": "^16.4.5", "express": "^4.21.0", - "install": "^0.13.0" + "install": "^0.13.0", + "jsonwebtoken": "^9.0.2", + "mongoose": "^8.7.0" } } diff --git a/routes/indexRouter.js b/routes/indexRouter.js new file mode 100644 index 0000000..cf0a780 --- /dev/null +++ b/routes/indexRouter.js @@ -0,0 +1,9 @@ +const express = require("express"); + +const router = express.Router(); + +router.get("/", (req, res) => { + res.send("Hello World!"); +}); + +module.exports = router; diff --git a/routes/userRouter.js b/routes/userRouter.js index 187f577..8e1c9c9 100644 --- a/routes/userRouter.js +++ b/routes/userRouter.js @@ -6,4 +6,7 @@ const userController = require("../controller/userController"); //로그인API 호출 router.post("/login", userController.login); +//회원가입API 호출 +router.post("/signup", userController.signup); + module.exports = router; \ No newline at end of file diff --git a/schema/user.js b/schema/user.js index 8875d67..d248bb8 100644 --- a/schema/user.js +++ b/schema/user.js @@ -16,3 +16,6 @@ const userSchema = new Schema({ // User 모델 생성 const User = mongoose.model('User', userSchema); + + +module.exports = User; \ No newline at end of file From 845fa7571fe9ac7a3892213672815b40a15af010 Mon Sep 17 00:00:00 2001 From: daesung Date: Sat, 28 Sep 2024 17:50:45 +0900 Subject: [PATCH 02/27] =?UTF-8?q?nodemon=20=EC=84=A4=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 300 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 + 2 files changed, 303 insertions(+) diff --git a/package-lock.json b/package-lock.json index eb988b4..32a2a7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,9 @@ "install": "^0.13.0", "jsonwebtoken": "^9.0.2", "mongoose": "^8.7.0" + }, + "devDependencies": { + "nodemon": "^3.1.7" } }, "node_modules/@mapbox/node-pre-gyp": { @@ -115,6 +118,19 @@ "node": ">=8" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/aproba": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", @@ -157,6 +173,18 @@ "node": ">= 10.0.0" } }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/body-parser": { "version": "1.20.3", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", @@ -190,6 +218,18 @@ "concat-map": "0.0.1" } }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/bson": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/bson/-/bson-6.8.0.tgz", @@ -231,6 +271,30 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", @@ -468,6 +532,18 @@ "node": ">= 0.10.0" } }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/finalhandler": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", @@ -531,6 +607,20 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -599,6 +689,18 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -611,6 +713,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/has-property-descriptors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", @@ -725,6 +836,12 @@ "node": ">=0.10.0" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -759,6 +876,27 @@ "node": ">= 0.10" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -767,6 +905,27 @@ "node": ">=8" } }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/jsonwebtoken": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", @@ -1173,6 +1332,57 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/nodemon": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", + "integrity": "sha512-hLj7fuMow6f0lbB0cD14Lz2xNjwsyruH251Pk4t/yIitCFJbmY1myuLlHm/q06aST4jg6EgAh74PIBBrRqpVAQ==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/nodemon/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, "node_modules/nopt": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", @@ -1187,6 +1397,15 @@ "node": ">=6" } }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/npmlog": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", @@ -1262,6 +1481,18 @@ "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", "license": "MIT" }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -1275,6 +1506,12 @@ "node": ">= 0.10" } }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -1335,6 +1572,18 @@ "node": ">= 6" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -1497,6 +1746,18 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/sparse-bitfield": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", @@ -1546,6 +1807,18 @@ "node": ">=8" } }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/tar": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", @@ -1562,6 +1835,18 @@ "node": ">=10" } }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -1571,6 +1856,15 @@ "node": ">=0.6" } }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, "node_modules/tr46": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", @@ -1595,6 +1889,12 @@ "node": ">= 0.6" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index 58ae97b..4965d06 100644 --- a/package.json +++ b/package.json @@ -16,5 +16,8 @@ "install": "^0.13.0", "jsonwebtoken": "^9.0.2", "mongoose": "^8.7.0" + }, + "devDependencies": { + "nodemon": "^3.1.7" } } From 3e3da14fdaa5b80e540cc5f1528af6c964c17057 Mon Sep 17 00:00:00 2001 From: daesung Date: Sat, 28 Sep 2024 19:08:12 +0900 Subject: [PATCH 03/27] =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8,=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/userController.js | 47 ++++++++++++++++++++++++++---------- schema/user.js | 2 +- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/controller/userController.js b/controller/userController.js index 38eadd2..c43e4d9 100644 --- a/controller/userController.js +++ b/controller/userController.js @@ -2,11 +2,39 @@ const User = require("../schema/user"); // User 모델 가져오기 const bcrypt = require("bcrypt"); const jwt = require("jsonwebtoken"); -exports.login = async(req, res, next) => { +exports.login = async (req, res) => { + const { username, password } = req.body; + + try { + // 1. 사용자 찾기 + const user = await User.findOne({ username }); + if (!user) { + return res.status(400).json({ message: "Invalid username or password" }); + } + + // 2. 비밀번호 비교 + const isMatch = await bcrypt.compare(password, user.password); + if (!isMatch) { + return res.status(400).json({ message: "Invalid username or password" }); + } + + // 3. JWT 토큰 발급 + const token = jwt.sign( + { userId: user._id, username: user.username }, + "your_jwt_secret", // 비밀키 (환경 변수로 관리하는 것이 좋습니다) + { expiresIn: "1h" } // 토큰 유효기간 + ); -} + // 4. 토큰 반환 + return res.status(200).json({ token }); -exports.signup = async (req, res, next) => { + } catch (error) { + console.error(error); + res.status(500).json({ message: "Server error" }); + } +}; + +exports.signup = async (req, res) => { const { username, password } = req.body; try { @@ -26,16 +54,9 @@ exports.signup = async (req, res, next) => { }); await newUser.save(); - - // 4. JWT 토큰 발급 - const token = jwt.sign( - { userId: newUser._id, username: newUser.username }, - "your_jwt_secret", // 비밀키 (환경 변수로 관리) - { expiresIn: "1h" } // 토큰 유효 기간 설정 - ); - - // 5. 응답으로 토큰 반환 - return res.status(201).json({ token }); + + // 5. 응답으로 회원정보 반환 + return res.status(201).json({ newUser }); } catch (error) { console.error(error); diff --git a/schema/user.js b/schema/user.js index d248bb8..f439f43 100644 --- a/schema/user.js +++ b/schema/user.js @@ -7,7 +7,7 @@ const userSchema = new Schema({ type: String, required: true, unique: true, // 중복검사 - }, + }, password: { type: String, required: true, From 439c7b8074e61961c31bd6b598f9c774678fc8c5 Mon Sep 17 00:00:00 2001 From: daesung Date: Sat, 28 Sep 2024 19:33:39 +0900 Subject: [PATCH 04/27] =?UTF-8?q?=EC=8A=A4=ED=82=A4=EB=A7=88=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20&=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EC=98=A4=EB=A5=98=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/userController.js | 7 +++++-- middlewares/auth.js | 26 ++++++++++++++++++++++++++ routes/userRouter.js | 1 + schema/user.js | 4 ++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/controller/userController.js b/controller/userController.js index c43e4d9..d8d4e17 100644 --- a/controller/userController.js +++ b/controller/userController.js @@ -20,10 +20,13 @@ exports.login = async (req, res) => { // 3. JWT 토큰 발급 const token = jwt.sign( - { userId: user._id, username: user.username }, + { username: user.username }, "your_jwt_secret", // 비밀키 (환경 변수로 관리하는 것이 좋습니다) { expiresIn: "1h" } // 토큰 유효기간 ); + + // 액세스 토큰을 Authorization 헤더에 추가 + res.setHeader("Authorization", `Bearer ${accessToken}`); // 4. 토큰 반환 return res.status(200).json({ token }); @@ -54,7 +57,7 @@ exports.signup = async (req, res) => { }); await newUser.save(); - + // 5. 응답으로 회원정보 반환 return res.status(201).json({ newUser }); diff --git a/middlewares/auth.js b/middlewares/auth.js index e69de29..45431ed 100644 --- a/middlewares/auth.js +++ b/middlewares/auth.js @@ -0,0 +1,26 @@ +const jwt = require("jsonwebtoken"); + +//로그인했는지 검사 +function authenticateJWT(req, res, next) { + const authHeader = req.headers.authorization; + + if (authHeader) { + const token = authHeader.split(" ")[1]; + + jwt.verify(token, process.env.SECRETKEY, (err, user) => { + if (err) { + return res.sendStatus(403).send({ message: '토큰 검증 실패' }); // Forbidden: Invalid token + } + if(!allowedRoles.includes(user.role)) { + return res.status(403).send({ message: '권한이 없습니다.' }); + } + + req.user = user; + next(); // 토큰이 유효한 경우, 다음 미들웨어나 라우트 핸들러로 이동 + }); + } else { + res.sendStatus(401); // Unauthorized: No token provided + } +} + +module.exports = { authenticateJWT }; diff --git a/routes/userRouter.js b/routes/userRouter.js index 8e1c9c9..d481590 100644 --- a/routes/userRouter.js +++ b/routes/userRouter.js @@ -1,6 +1,7 @@ const express = require("express"); const router = express.Router(); const userController = require("../controller/userController"); +const { authenticateJWT } = require("../middlewares/auth"); //로그인API 호출 diff --git a/schema/user.js b/schema/user.js index f439f43..c79d5db 100644 --- a/schema/user.js +++ b/schema/user.js @@ -11,6 +11,10 @@ const userSchema = new Schema({ password: { type: String, required: true, + }, + nickname: { + type: String, + required: true } }); From 0c8c739243f5c2f2ceb733a7f4172ebba0b7e3dd Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 19:58:06 +0900 Subject: [PATCH 05/27] commit --- controller/quizController.js | 58 ++++++++++++++++++++++++++++++++++++ routes/quizRouter.js | 13 ++++++++ 2 files changed, 71 insertions(+) create mode 100644 controller/quizController.js create mode 100644 routes/quizRouter.js diff --git a/controller/quizController.js b/controller/quizController.js new file mode 100644 index 0000000..7c145a5 --- /dev/null +++ b/controller/quizController.js @@ -0,0 +1,58 @@ +const express = require('express') +const axios = require('axios') +router.use(express.json()) + +const {body, param, validationResult} = require('express-validator') +const Quiz = require('../schema/quiz'); + + + +exports.getQuiz = async (req, res) => { + const {id} = req.params; + try { + const quiz = await Quiz.findById(id); + if (quiz) { + const wordList = quiz.question.split(' ') + res.status(200).json({ + words : wordList + }) + } else { + res.status(404).json({ message : "잘못된 요청입니다."}) + } + } catch (err) { + res.status(500).json({message : "잘못된 요청입니다."}) + } + } + +exports.submitQuiz = async (req, res) => { + const {answer} = req.body + const {id} = req.params + try { + const quiz = await Quiz.findById(id) + + if(!quiz) { + return res.status(404).json({ message : "퀴즈가 없습니다."}) + } + if (quiz.answer == answer) { + try { + const fruitResponse = await axios.get('./tree/fruit') + res.status(200).json({ + message : "정답입니다", + fruitData : fruitResponse.data + }) + } catch (error) { + res.status(500).json({ + message : "정답이지만 fruit api요청 중 오류 발생", + error : error.message + }) + } + } else { + res.status(200).json({ + message : "틀렸습니다.", + correctAnswer : quiz.answer + }) + } + } catch (err) { + res.status(500).json({message : "서버오류", error : err}) + } + } diff --git a/routes/quizRouter.js b/routes/quizRouter.js new file mode 100644 index 0000000..80ed98e --- /dev/null +++ b/routes/quizRouter.js @@ -0,0 +1,13 @@ +const express = require("express"); +const router = express.Router(); +const quizController = require("../controller/quizController"); +const { authenticateJWT } = require("../middlewares/auth"); + +router.use(express.json()) +//로그인API 호출 + +router.get("/quiz/:id", quizController.getQuiz) +//회원가입API 호출 +router.post("/quiz/:id", quizController.submitQuiz); + +module.exports = router; \ No newline at end of file From 16ad4c8eb3acfb86558798924a93441074262c97 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 19:58:06 +0900 Subject: [PATCH 06/27] commit --- controller/quizController.js | 58 ++++++++++++++++++++++++++++++++++++ routes/quizRouter.js | 13 ++++++++ 2 files changed, 71 insertions(+) create mode 100644 controller/quizController.js create mode 100644 routes/quizRouter.js diff --git a/controller/quizController.js b/controller/quizController.js new file mode 100644 index 0000000..7c145a5 --- /dev/null +++ b/controller/quizController.js @@ -0,0 +1,58 @@ +const express = require('express') +const axios = require('axios') +router.use(express.json()) + +const {body, param, validationResult} = require('express-validator') +const Quiz = require('../schema/quiz'); + + + +exports.getQuiz = async (req, res) => { + const {id} = req.params; + try { + const quiz = await Quiz.findById(id); + if (quiz) { + const wordList = quiz.question.split(' ') + res.status(200).json({ + words : wordList + }) + } else { + res.status(404).json({ message : "잘못된 요청입니다."}) + } + } catch (err) { + res.status(500).json({message : "잘못된 요청입니다."}) + } + } + +exports.submitQuiz = async (req, res) => { + const {answer} = req.body + const {id} = req.params + try { + const quiz = await Quiz.findById(id) + + if(!quiz) { + return res.status(404).json({ message : "퀴즈가 없습니다."}) + } + if (quiz.answer == answer) { + try { + const fruitResponse = await axios.get('./tree/fruit') + res.status(200).json({ + message : "정답입니다", + fruitData : fruitResponse.data + }) + } catch (error) { + res.status(500).json({ + message : "정답이지만 fruit api요청 중 오류 발생", + error : error.message + }) + } + } else { + res.status(200).json({ + message : "틀렸습니다.", + correctAnswer : quiz.answer + }) + } + } catch (err) { + res.status(500).json({message : "서버오류", error : err}) + } + } diff --git a/routes/quizRouter.js b/routes/quizRouter.js new file mode 100644 index 0000000..80ed98e --- /dev/null +++ b/routes/quizRouter.js @@ -0,0 +1,13 @@ +const express = require("express"); +const router = express.Router(); +const quizController = require("../controller/quizController"); +const { authenticateJWT } = require("../middlewares/auth"); + +router.use(express.json()) +//로그인API 호출 + +router.get("/quiz/:id", quizController.getQuiz) +//회원가입API 호출 +router.post("/quiz/:id", quizController.submitQuiz); + +module.exports = router; \ No newline at end of file From 0979d1d792193c0e9c21b212dd3569f75d8c145c Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 20:49:40 +0900 Subject: [PATCH 07/27] commit --- controller/quizController.js | 101 +++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 45 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index 7c145a5..303b5ef 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -1,58 +1,69 @@ -const express = require('express') -const axios = require('axios') -router.use(express.json()) - -const {body, param, validationResult} = require('express-validator') +const axios = require('axios'); +const { body, param, validationResult } = require('express-validator'); const Quiz = require('../schema/quiz'); +const validate = (req, res, next) => { + const err = validationResult(req); + if (err.isEmpty()) { + return next(); + } else { + return res.status(400).json(err.array()); + } +}; - +// 퀴즈 조회 exports.getQuiz = async (req, res) => { - const {id} = req.params; - try { - const quiz = await Quiz.findById(id); - if (quiz) { - const wordList = quiz.question.split(' ') - res.status(200).json({ - words : wordList - }) - } else { - res.status(404).json({ message : "잘못된 요청입니다."}) - } - } catch (err) { - res.status(500).json({message : "잘못된 요청입니다."}) + const { id } = req.params; + + if (!mongoose.Types.ObjectId.isValid(id)) { + return res.status(400).json({message: "유효하지 않은 id"}) + } + try { + const quiz = await Quiz.findById(mongoose.Types.ObjectId(id)); + if (quiz) { + const wordList = quiz.question.split(' '); + res.status(200).json({ words: wordList }); + } else { + res.status(404).json({ message: "잘못된 요청입니다." }); } + } catch (err) { + res.status(500).json({ message: "서버 오류입니다.", error: err }); } +}; +// 퀴즈 제출 exports.submitQuiz = async (req, res) => { - const {answer} = req.body - const {id} = req.params - try { - const quiz = await Quiz.findById(id) + const { answer } = req.body; + const { id } = req.params; + if (!mongoose.Types.ObjectId.isValid(id)) { + return res.status(400).json({message: "유효하지 않은 id"}) + } - if(!quiz) { - return res.status(404).json({ message : "퀴즈가 없습니다."}) - } - if (quiz.answer == answer) { - try { - const fruitResponse = await axios.get('./tree/fruit') - res.status(200).json({ - message : "정답입니다", - fruitData : fruitResponse.data - }) - } catch (error) { - res.status(500).json({ - message : "정답이지만 fruit api요청 중 오류 발생", - error : error.message - }) - } - } else { + try { + const quiz = await Quiz.findById(mongoose.Types.ObjectId(id)); + if (!quiz) { + return res.status(404).json({ message: "퀴즈가 없습니다." }); + } + if (quiz.answer == answer) { + try { + const fruitResponse = await axios.get('http://your-api-url.com/tree/fruit'); // 절대 URL로 변경 res.status(200).json({ - message : "틀렸습니다.", - correctAnswer : quiz.answer - }) + message: "정답입니다.", + fruitData: fruitResponse.data + }); + } catch (error) { + res.status(500).json({ + message: "정답이지만 fruit API 요청 중 오류 발생.", + error: error.message + }); } - } catch (err) { - res.status(500).json({message : "서버오류", error : err}) + } else { + res.status(200).json({ + message: "틀렸습니다.", + correctAnswer: quiz.answer + }); } + } catch (err) { + res.status(500).json({ message: "서버 오류입니다.", error: err }); } +}; From eef4c23180fd43037ead7e17d267c1e073055c9f Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 20:50:33 +0900 Subject: [PATCH 08/27] commit --- controller/quizController.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index 303b5ef..08741fe 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -1,16 +1,6 @@ const axios = require('axios'); -const { body, param, validationResult } = require('express-validator'); const Quiz = require('../schema/quiz'); -const validate = (req, res, next) => { - const err = validationResult(req); - if (err.isEmpty()) { - return next(); - } else { - return res.status(400).json(err.array()); - } -}; - // 퀴즈 조회 exports.getQuiz = async (req, res) => { const { id } = req.params; From 04792a0332358dd070d47a11607c3e9a63990276 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 20:51:09 +0900 Subject: [PATCH 09/27] commit --- routes/quizRouter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/quizRouter.js b/routes/quizRouter.js index 80ed98e..d920682 100644 --- a/routes/quizRouter.js +++ b/routes/quizRouter.js @@ -6,8 +6,8 @@ const { authenticateJWT } = require("../middlewares/auth"); router.use(express.json()) //로그인API 호출 -router.get("/quiz/:id", quizController.getQuiz) +router.get("/:id", quizController.getQuiz) //회원가입API 호출 -router.post("/quiz/:id", quizController.submitQuiz); +router.post("/:id", quizController.submitQuiz); module.exports = router; \ No newline at end of file From 26e8c220b9e59b7598186442fb4357fa42fb27ba Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 21:05:39 +0900 Subject: [PATCH 10/27] commit --- controller/quizController.js | 12 +++--------- schema/quiz.js | 5 +++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index 08741fe..850bd4c 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -1,15 +1,12 @@ const axios = require('axios'); const Quiz = require('../schema/quiz'); - +const mongoose = require('mongoose') // 퀴즈 조회 exports.getQuiz = async (req, res) => { const { id } = req.params; - if (!mongoose.Types.ObjectId.isValid(id)) { - return res.status(400).json({message: "유효하지 않은 id"}) - } try { - const quiz = await Quiz.findById(mongoose.Types.ObjectId(id)); + const quiz = await Quiz.findOne({id}); if (quiz) { const wordList = quiz.question.split(' '); res.status(200).json({ words: wordList }); @@ -25,12 +22,9 @@ exports.getQuiz = async (req, res) => { exports.submitQuiz = async (req, res) => { const { answer } = req.body; const { id } = req.params; - if (!mongoose.Types.ObjectId.isValid(id)) { - return res.status(400).json({message: "유효하지 않은 id"}) - } try { - const quiz = await Quiz.findById(mongoose.Types.ObjectId(id)); + const quiz = await Quiz.findOne({id}); if (!quiz) { return res.status(404).json({ message: "퀴즈가 없습니다." }); } diff --git a/schema/quiz.js b/schema/quiz.js index 266261b..d242eb5 100644 --- a/schema/quiz.js +++ b/schema/quiz.js @@ -1,5 +1,10 @@ // Quiz 스키마 정의 const quizSchema = new Schema({ + id : { + type : Schema.Types.ObjectId, + required : true, + unique : true + }, question: { type: String, required: true, From 18d56b9657d8211ad4b64638ad49424fab34ba7c Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 21:07:24 +0900 Subject: [PATCH 11/27] commit --- controller/quizController.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index 850bd4c..ab329f9 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -25,9 +25,6 @@ exports.submitQuiz = async (req, res) => { try { const quiz = await Quiz.findOne({id}); - if (!quiz) { - return res.status(404).json({ message: "퀴즈가 없습니다." }); - } if (quiz.answer == answer) { try { const fruitResponse = await axios.get('http://your-api-url.com/tree/fruit'); // 절대 URL로 변경 From 5df2816fcc1aac3fcbad34f23cb5429ab34a841b Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 21:08:11 +0900 Subject: [PATCH 12/27] commit --- controller/quizController.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controller/quizController.js b/controller/quizController.js index ab329f9..850bd4c 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -25,6 +25,9 @@ exports.submitQuiz = async (req, res) => { try { const quiz = await Quiz.findOne({id}); + if (!quiz) { + return res.status(404).json({ message: "퀴즈가 없습니다." }); + } if (quiz.answer == answer) { try { const fruitResponse = await axios.get('http://your-api-url.com/tree/fruit'); // 절대 URL로 변경 From 61a3d75ab6339358dabb2da1f37ce6189e3d561c Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 21:57:23 +0900 Subject: [PATCH 13/27] commit --- controller/quizController.js | 5 ++--- schema/quiz.js | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index 850bd4c..a06bc7f 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -30,10 +30,9 @@ exports.submitQuiz = async (req, res) => { } if (quiz.answer == answer) { try { - const fruitResponse = await axios.get('http://your-api-url.com/tree/fruit'); // 절대 URL로 변경 + const fruitResponse = await axios.get('http://localhost/tree/fruit'); // 절대 URL로 변경 res.status(200).json({ - message: "정답입니다.", - fruitData: fruitResponse.data + message: "정답입니다." }); } catch (error) { res.status(500).json({ diff --git a/schema/quiz.js b/schema/quiz.js index d242eb5..10a956b 100644 --- a/schema/quiz.js +++ b/schema/quiz.js @@ -1,7 +1,8 @@ // Quiz 스키마 정의 +const mongo = require('mongoose') const quizSchema = new Schema({ id : { - type : Schema.Types.ObjectId, + type : mongoose.Schema.Types.ObjectId, required : true, unique : true }, From 3108ec2804996392cbe8f4d399b2f6cb610577ff Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 22:07:45 +0900 Subject: [PATCH 14/27] commit --- controller/quizController.js | 3 ++- routes/quizRouter.js | 4 ++-- schema/quiz.js | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index a06bc7f..8026272 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -22,6 +22,7 @@ exports.getQuiz = async (req, res) => { exports.submitQuiz = async (req, res) => { const { answer } = req.body; const { id } = req.params; + const user = req.user; try { const quiz = await Quiz.findOne({id}); @@ -30,7 +31,7 @@ exports.submitQuiz = async (req, res) => { } if (quiz.answer == answer) { try { - const fruitResponse = await axios.get('http://localhost/tree/fruit'); // 절대 URL로 변경 + const fruitResponse = await axios.post('http://localhost:3000/tree/fruit', user); // 절대 URL로 변경 res.status(200).json({ message: "정답입니다." }); diff --git a/routes/quizRouter.js b/routes/quizRouter.js index d920682..9709e8e 100644 --- a/routes/quizRouter.js +++ b/routes/quizRouter.js @@ -6,8 +6,8 @@ const { authenticateJWT } = require("../middlewares/auth"); router.use(express.json()) //로그인API 호출 -router.get("/:id", quizController.getQuiz) +router.get("/:id", authenticateJWT, quizController.getQuiz) //회원가입API 호출 -router.post("/:id", quizController.submitQuiz); +router.post("/:id", authenticateJWT, quizController.submitQuiz); module.exports = router; \ No newline at end of file diff --git a/schema/quiz.js b/schema/quiz.js index 10a956b..aaae69b 100644 --- a/schema/quiz.js +++ b/schema/quiz.js @@ -1,8 +1,8 @@ // Quiz 스키마 정의 const mongo = require('mongoose') -const quizSchema = new Schema({ +const quizSchema = new mongo.Schema({ id : { - type : mongoose.Schema.Types.ObjectId, + type : String, required : true, unique : true }, From 80a39cd618beaebab268a370cb93d58016dcb1c7 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 22:13:06 +0900 Subject: [PATCH 15/27] commit --- schema/quiz.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/quiz.js b/schema/quiz.js index aaae69b..faf8192 100644 --- a/schema/quiz.js +++ b/schema/quiz.js @@ -17,4 +17,4 @@ const quizSchema = new mongo.Schema({ }); // Quiz 모델 생성 -const Quiz = mongoose.model('Quiz', quizSchema); +const Quiz = mongo.model('Quiz', quizSchema); From dfe054cba2296325929dfd973db6bfe1c8f69ae6 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 22:52:09 +0900 Subject: [PATCH 16/27] commit --- controller/userInfoController.js | 17 +++++++++++++++++ routes/userInfoRouter.js | 10 ++++++++++ 2 files changed, 27 insertions(+) create mode 100644 controller/userInfoController.js create mode 100644 routes/userInfoRouter.js diff --git a/controller/userInfoController.js b/controller/userInfoController.js new file mode 100644 index 0000000..3f0add0 --- /dev/null +++ b/controller/userInfoController.js @@ -0,0 +1,17 @@ +const axios = require('axios'); +const User = require('../schema/user'); +const mongoose = require('mongoose') +// 퀴즈 조회 +exports.info = async (req, res) => { + + try { + const user = await User.findOne({ username }) + if (user) { + res.status(200).json(user); + } else { + res.status(404).json({ message: "잘못된 요청입니다." }); + } + } catch (err) { + res.status(500).json({ message: "서버 오류입니다.", error: err }); + } +}; diff --git a/routes/userInfoRouter.js b/routes/userInfoRouter.js new file mode 100644 index 0000000..3820fd8 --- /dev/null +++ b/routes/userInfoRouter.js @@ -0,0 +1,10 @@ +const express = require("express"); +const router = express.Router(); +const userInfoController = require("../controller/userInfoController"); +const { authenticateJWT } = require("../middlewares/auth"); + + +//로그인API 호출 +router.post("/", userInfoController.info); + +module.exports = router; \ No newline at end of file From 163650059d9063d69d8a9b4f6363ed740c2a8f31 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 23:11:24 +0900 Subject: [PATCH 17/27] commit --- controller/quizController.js | 11 +++++++++-- controller/userInfoController.js | 9 ++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index 8026272..5518ea3 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -4,12 +4,17 @@ const mongoose = require('mongoose') // 퀴즈 조회 exports.getQuiz = async (req, res) => { const { id } = req.params; - + const {index} = req.body try { const quiz = await Quiz.findOne({id}); if (quiz) { const wordList = quiz.question.split(' '); - res.status(200).json({ words: wordList }); + + if (index < 0 || index >= wordList.length) { + return res.status(400).end() + } + + res.status(200).json({ words: wordList, index : index }); } else { res.status(404).json({ message: "잘못된 요청입니다." }); } @@ -51,3 +56,5 @@ exports.submitQuiz = async (req, res) => { res.status(500).json({ message: "서버 오류입니다.", error: err }); } }; + +//인덱스 잘라서 주기 \ No newline at end of file diff --git a/controller/userInfoController.js b/controller/userInfoController.js index 3f0add0..2fcf999 100644 --- a/controller/userInfoController.js +++ b/controller/userInfoController.js @@ -3,11 +3,14 @@ const User = require('../schema/user'); const mongoose = require('mongoose') // 퀴즈 조회 exports.info = async (req, res) => { - + const {username} = req.body try { - const user = await User.findOne({ username }) + const user = await User.findOne({ username : username }) if (user) { - res.status(200).json(user); + res.status(200).json({ + name : user.name, + password : user.password, + email : user.email}); } else { res.status(404).json({ message: "잘못된 요청입니다." }); } From 62ec9f4f77d080aff716665ef45ce4df8546ab2b Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 23:11:35 +0900 Subject: [PATCH 18/27] c --- routes/userInfoRouter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/userInfoRouter.js b/routes/userInfoRouter.js index 3820fd8..91973fe 100644 --- a/routes/userInfoRouter.js +++ b/routes/userInfoRouter.js @@ -3,8 +3,8 @@ const router = express.Router(); const userInfoController = require("../controller/userInfoController"); const { authenticateJWT } = require("../middlewares/auth"); - +router.use(express.json()) //로그인API 호출 -router.post("/", userInfoController.info); +router.post("/", authenticateJWT, userInfoController.info); module.exports = router; \ No newline at end of file From f5512e225f89c5b52d2b0977fa591874ecc6716b Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 23:13:07 +0900 Subject: [PATCH 19/27] co --- controller/quizController.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index 5518ea3..072d116 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -8,12 +8,11 @@ exports.getQuiz = async (req, res) => { try { const quiz = await Quiz.findOne({id}); if (quiz) { - const wordList = quiz.question.split(' '); - + const wordList = quiz.question if (index < 0 || index >= wordList.length) { return res.status(400).end() } - + res.status(200).json({ words: wordList, index : index }); } else { res.status(404).json({ message: "잘못된 요청입니다." }); From 13455d43a3ee499de9c140f1dd63a0176410e6d9 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 23:26:59 +0900 Subject: [PATCH 20/27] co --- controller/quizController.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/controller/quizController.js b/controller/quizController.js index 072d116..8038a67 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -9,11 +9,8 @@ exports.getQuiz = async (req, res) => { const quiz = await Quiz.findOne({id}); if (quiz) { const wordList = quiz.question - if (index < 0 || index >= wordList.length) { - return res.status(400).end() - } - res.status(200).json({ words: wordList, index : index }); + res.status(200).json({ words: wordList, index }); } else { res.status(404).json({ message: "잘못된 요청입니다." }); } From fa4a021446175b78d36bf9ddb64022a0d05cd710 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 23:35:58 +0900 Subject: [PATCH 21/27] c --- controller/userInfoController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/userInfoController.js b/controller/userInfoController.js index 2fcf999..cc9fa55 100644 --- a/controller/userInfoController.js +++ b/controller/userInfoController.js @@ -3,9 +3,9 @@ const User = require('../schema/user'); const mongoose = require('mongoose') // 퀴즈 조회 exports.info = async (req, res) => { - const {username} = req.body + const {userID} = req.body try { - const user = await User.findOne({ username : username }) + const user = await User.findOne({ userID : userID}) if (user) { res.status(200).json({ name : user.name, From 5baf39195cb9f11a98837916df3488d8dbda14c0 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 23:39:17 +0900 Subject: [PATCH 22/27] c --- controller/userInfoController.js | 2 +- index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/controller/userInfoController.js b/controller/userInfoController.js index cc9fa55..62ef70c 100644 --- a/controller/userInfoController.js +++ b/controller/userInfoController.js @@ -10,7 +10,7 @@ exports.info = async (req, res) => { res.status(200).json({ name : user.name, password : user.password, - email : user.email}); + nickname : user.nickname}); } else { res.status(404).json({ message: "잘못된 요청입니다." }); } diff --git a/index.js b/index.js index f04cb58..78be7ad 100644 --- a/index.js +++ b/index.js @@ -20,10 +20,10 @@ mongoose.connect(process.env.MONGO_URI, { // 라우터 사용 const indexRouter = require("./routes/indexRouter"); const userRouter = require('./routes/userRouter'); - +const userInfoRouter = require('./routes/userInfoRouter') app.use("/", indexRouter); app.use("/user", userRouter); // 예: /user 경로에서 userRouter 사용 - +app.use("/info", userInfoRouter) // 서버 시작 const PORT = process.env.PORT || 3000; app.listen(PORT, () => { From 023a221feb2132b54486448038156056d8591091 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sat, 28 Sep 2024 23:43:30 +0900 Subject: [PATCH 23/27] c --- controller/userInfoController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/userInfoController.js b/controller/userInfoController.js index 62ef70c..70785ac 100644 --- a/controller/userInfoController.js +++ b/controller/userInfoController.js @@ -8,7 +8,7 @@ exports.info = async (req, res) => { const user = await User.findOne({ userID : userID}) if (user) { res.status(200).json({ - name : user.name, + name : user.username, password : user.password, nickname : user.nickname}); } else { From 9e8fd458a2a62d871aa0118aebf7a715fb2ef7f1 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sun, 29 Sep 2024 01:03:41 +0900 Subject: [PATCH 24/27] c --- controller/userInfoController.js | 1 + routes/userInfoRouter.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/userInfoController.js b/controller/userInfoController.js index 70785ac..4dd90ce 100644 --- a/controller/userInfoController.js +++ b/controller/userInfoController.js @@ -5,6 +5,7 @@ const mongoose = require('mongoose') exports.info = async (req, res) => { const {userID} = req.body try { + const user = await User.findOne({ userID : userID}) if (user) { res.status(200).json({ diff --git a/routes/userInfoRouter.js b/routes/userInfoRouter.js index 91973fe..1b63060 100644 --- a/routes/userInfoRouter.js +++ b/routes/userInfoRouter.js @@ -6,5 +6,4 @@ const { authenticateJWT } = require("../middlewares/auth"); router.use(express.json()) //로그인API 호출 router.post("/", authenticateJWT, userInfoController.info); - module.exports = router; \ No newline at end of file From ce6720992308c728c762e3f79d412c5a8c1e3c39 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sun, 29 Sep 2024 01:12:16 +0900 Subject: [PATCH 25/27] c --- controller/quizController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/quizController.js b/controller/quizController.js index 8038a67..1dfaed2 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -32,7 +32,7 @@ exports.submitQuiz = async (req, res) => { } if (quiz.answer == answer) { try { - const fruitResponse = await axios.post('http://localhost:3000/tree/fruit', user); // 절대 URL로 변경 + const fruitResponse = await axios.post('http://localhost:8080/tree/fruit', user); // 절대 URL로 변경 res.status(200).json({ message: "정답입니다." }); From 71e65aca87323b582a4153ef0dc7af07de529a57 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sun, 29 Sep 2024 01:12:23 +0900 Subject: [PATCH 26/27] c --- controller/quizController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/quizController.js b/controller/quizController.js index 1dfaed2..664b3d7 100644 --- a/controller/quizController.js +++ b/controller/quizController.js @@ -10,7 +10,7 @@ exports.getQuiz = async (req, res) => { if (quiz) { const wordList = quiz.question - res.status(200).json({ words: wordList, index }); + res.status(200).json({ words: wordList, index, id}); } else { res.status(404).json({ message: "잘못된 요청입니다." }); } From 16886509bcf769d93e6c8f6c28faade70b7d6ec0 Mon Sep 17 00:00:00 2001 From: 20223096 Date: Sun, 29 Sep 2024 01:20:30 +0900 Subject: [PATCH 27/27] c --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index 78be7ad..214dff6 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,7 @@ mongoose.connect(process.env.MONGO_URI, { const indexRouter = require("./routes/indexRouter"); const userRouter = require('./routes/userRouter'); const userInfoRouter = require('./routes/userInfoRouter') + app.use("/", indexRouter); app.use("/user", userRouter); // 예: /user 경로에서 userRouter 사용 app.use("/info", userInfoRouter)