From 4be5ec4cc4e44612f5226812c9ccc7a50076d6e6 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 1 May 2023 13:37:24 +0900 Subject: [PATCH 01/70] =?UTF-8?q?#18=20gitignore=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/.gitignore | 141 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 server/.gitignore diff --git a/server/.gitignore b/server/.gitignore new file mode 100644 index 000000000..131d38251 --- /dev/null +++ b/server/.gitignore @@ -0,0 +1,141 @@ +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +# End of https://www.toptal.com/developers/gitignore/api/node \ No newline at end of file From e7a2dd80c726bf4cdcc34a9db6279edb4e9a93d5 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 1 May 2023 14:34:34 +0900 Subject: [PATCH 02/70] =?UTF-8?q?#18=20express=20=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app.js | 13 + server/package-lock.json | 1593 +++++++++++++++++++++++++++++++ server/package.json | 20 + server/remote.txt | 1 - server/src/routes/home/index.js | 10 + 5 files changed, 1636 insertions(+), 1 deletion(-) create mode 100644 server/app.js create mode 100644 server/package-lock.json create mode 100644 server/package.json delete mode 100644 server/remote.txt create mode 100644 server/src/routes/home/index.js diff --git a/server/app.js b/server/app.js new file mode 100644 index 000000000..8a56c4f09 --- /dev/null +++ b/server/app.js @@ -0,0 +1,13 @@ +"use strict"; + +// 모듈 +const express = require("express"); +const app = express(); + +// 라우팅 +const home = require("./src/routes/home"); + +// 미들웨어 +app.use("/", home); + +module.exports = app; \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json new file mode 100644 index 000000000..a4841b298 --- /dev/null +++ b/server/package-lock.json @@ -0,0 +1,1593 @@ +{ + "name": "server", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "server", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "express": "^4.18.2", + "nodemon": "^2.0.22" + }, + "bin": { + "server": "www.js" + } + }, + "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", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "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==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "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==" + }, + "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/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/body-parser": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "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/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dependencies": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "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" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "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/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "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==" + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.5.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "node_modules/get-intrinsic": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", + "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==", + "dependencies": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "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==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "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==", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "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==" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "engines": { + "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==", + "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==", + "engines": { + "node": ">=0.10.0" + } + }, + "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==", + "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==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "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/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/nodemon": { + "version": "2.0.22", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz", + "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^3.2.7", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^5.7.1", + "simple-update-notifier": "^1.0.7", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=8.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dependencies": { + "ms": "^2.1.1" + } + }, + "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==" + }, + "node_modules/nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "*" + } + }, + "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==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "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", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "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==" + }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/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/serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "dependencies": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-update-notifier": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", + "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "dependencies": { + "semver": "~7.0.0" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/simple-update-notifier/node_modules/semver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", + "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "engines": { + "node": ">= 0.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==", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "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==", + "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", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "dependencies": { + "nopt": "~1.0.10" + }, + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "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==" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + } + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, + "accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "requires": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + } + }, + "anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, + "body-parser": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "requires": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" + }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.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" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "requires": { + "safe-buffer": "5.2.1" + } + }, + "content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==" + }, + "cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + }, + "destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" + }, + "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==" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" + }, + "express": { + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", + "requires": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.1", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.5.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.11.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + } + }, + "forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "get-intrinsic": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", + "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==", + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "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==" + }, + "has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" + }, + "http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "requires": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "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==" + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" + }, + "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==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==" + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "requires": { + "mime-db": "1.52.0" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" + }, + "nodemon": { + "version": "2.0.22", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz", + "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==", + "requires": { + "chokidar": "^3.5.2", + "debug": "^3.2.7", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^5.7.1", + "simple-update-notifier": "^1.0.7", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + } + } + }, + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", + "requires": { + "abbrev": "1" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "object-inspect": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==" + }, + "on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + }, + "proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "requires": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + } + }, + "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==" + }, + "qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "requires": { + "side-channel": "^1.0.4" + } + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "requires": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "requires": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "dependencies": { + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + } + } + }, + "serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + } + }, + "setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, + "simple-update-notifier": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", + "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "requires": { + "semver": "~7.0.0" + }, + "dependencies": { + "semver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", + "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==" + } + } + }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "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==", + "requires": { + "is-number": "^7.0.0" + } + }, + "toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" + }, + "touch": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", + "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", + "requires": { + "nopt": "~1.0.10" + } + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==" + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" + } + } +} diff --git a/server/package.json b/server/package.json new file mode 100644 index 000000000..80c93e7a5 --- /dev/null +++ b/server/package.json @@ -0,0 +1,20 @@ +{ + "name": "server", + "version": "1.0.0", + "description": "", + "main": "app.js", + "bin": { + "server": "www.js" + }, + "scripts": { + "start": "nodemon ./bin/www.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "express": "^4.18.2", + "nodemon": "^2.0.22" + } +} diff --git a/server/remote.txt b/server/remote.txt deleted file mode 100644 index 30d74d258..000000000 --- a/server/remote.txt +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/server/src/routes/home/index.js b/server/src/routes/home/index.js new file mode 100644 index 000000000..c6e16a718 --- /dev/null +++ b/server/src/routes/home/index.js @@ -0,0 +1,10 @@ +"use strict"; + +const express = require("express"); +const router = express.Router(); + +router.get("/", (req, res) => { + res.send("hello!"); +}) + +module.exports = router; \ No newline at end of file From 622e1a7d06b7c3f340542c3e2bf3cf2aa353a839 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 1 May 2023 14:37:31 +0900 Subject: [PATCH 03/70] =?UTF-8?q?#18=20=EC=84=9C=EB=B2=84=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89=ED=8C=8C=EC=9D=BC=20=EC=97=85=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/www.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 server/bin/www.js diff --git a/server/bin/www.js b/server/bin/www.js new file mode 100644 index 000000000..b9e6b5c69 --- /dev/null +++ b/server/bin/www.js @@ -0,0 +1,8 @@ +"use strict"; + +const app = require("../app"); +const PORT = process.env.PORT || 3000; // 포트 + +app.listen(PORT, () => { + console.log(`Server running on port ${PORT}`); +}); \ No newline at end of file From 02ac8df8e35e4790b5439be62d23d732e8465a44 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 1 May 2023 18:50:56 +0900 Subject: [PATCH 04/70] =?UTF-8?q?#18=20MCR=20=ED=8C=A8=ED=84=B4=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - server/app.js | 4 +- server/package-lock.json | 728 +++++++++++++++++++++++++++++++- server/package.json | 6 +- server/src/config/README.md | 1 + server/src/controller/README.md | 1 + server/src/models/README.md | 1 + server/src/routes/README.md | 1 + 8 files changed, 739 insertions(+), 4 deletions(-) create mode 100644 server/src/config/README.md create mode 100644 server/src/controller/README.md create mode 100644 server/src/models/README.md create mode 100644 server/src/routes/README.md diff --git a/.gitignore b/.gitignore index 56cc6425e..a53ec4b0b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ *.class # Generated files -bin/ gen/ out/ # Uncomment the following line in case you need and you don't have the release build type files in your app diff --git a/server/app.js b/server/app.js index 8a56c4f09..588f2a18c 100644 --- a/server/app.js +++ b/server/app.js @@ -3,11 +3,13 @@ // 모듈 const express = require("express"); const app = express(); +const dotenv = require("dotenv"); +dotenv.config(); // 라우팅 const home = require("./src/routes/home"); // 미들웨어 -app.use("/", home); +app.use("/", home); module.exports = app; \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json index a4841b298..3b8fab6d4 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -9,13 +9,40 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "dotenv": "^16.0.3", "express": "^4.18.2", - "nodemon": "^2.0.22" + "nodemon": "^2.0.22", + "oracledb": "^5.5.0", + "sequelize": "^6.31.0", + "sequelize-auto": "^0.8.8" }, "bin": { "server": "www.js" } }, + "node_modules/@types/debug": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", + "integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/ms": { + "version": "0.7.31", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", + "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" + }, + "node_modules/@types/node": { + "version": "18.16.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.3.tgz", + "integrity": "sha512-OPs5WnnT1xkCBiuQrZA4+YAV4HEJejmHneyraIaxsbev5yCEr6KMwINNFP9wQeFIw8FWcoTqF3vQsa5CDaI+8Q==" + }, + "node_modules/@types/validator": { + "version": "13.7.15", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.15.tgz", + "integrity": "sha512-yeinDVQunb03AEP8luErFcyf/7Lf7AzKCD0NXfgVoGCCQDNpZET8Jgq74oBgqKld3hafLbfzt/3inUdQvaFeXQ==" + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -33,6 +60,28 @@ "node": ">= 0.6" } }, + "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/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -152,6 +201,32 @@ "fsevents": "~2.3.2" } }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -214,11 +289,29 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "engines": { + "node": ">=12" + } + }, + "node_modules/dottie": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.3.tgz", + "integrity": "sha512-4liA0PuRkZWQFQjwBypdxPfZaRWiv5tkhMXY2hzsa2pNf5s7U3m9cwUchfNKe8wZQxdGPQQzO6Rm2uGe0rvohQ==" + }, "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==" }, + "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": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -227,6 +320,14 @@ "node": ">= 0.8" } }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -343,6 +444,14 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, "node_modules/get-intrinsic": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", @@ -428,6 +537,14 @@ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" }, + "node_modules/inflection": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz", + "integrity": "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw==", + "engines": [ + "node >= 0.4.0" + ] + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -460,6 +577,14 @@ "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", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -479,6 +604,22 @@ "node": ">=0.12.0" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -541,6 +682,36 @@ "node": "*" } }, + "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/moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", + "engines": { + "node": "*" + } + }, + "node_modules/moment-timezone": { + "version": "0.5.43", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz", + "integrity": "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==", + "dependencies": { + "moment": "^2.29.4" + }, + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -635,6 +806,15 @@ "node": ">= 0.8" } }, + "node_modules/oracledb": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/oracledb/-/oracledb-5.5.0.tgz", + "integrity": "sha512-i5cPvMENpZP8nnqptB6l0pjiOyySj1IISkbM4Hr3yZEDdANo2eezarwZb9NQ8fTh5pRjmgpZdSyIbnn9N3AENw==", + "hasInstallScript": true, + "engines": { + "node": ">=10.16" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -648,6 +828,11 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, + "node_modules/pg-connection-string": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz", + "integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==" + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -723,6 +908,24 @@ "node": ">=8.10.0" } }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/reserved-words": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz", + "integrity": "sha512-0S5SrIUJ9LfpbVl4Yzij6VipUdafHrOTzvmfazSw/jeZrZtQK303OPZW+obtkaw7jQlTQppy0UvZWm9872PbRw==" + }, + "node_modules/retry-as-promised": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.4.tgz", + "integrity": "sha512-XgmCoxKWkDofwH8WddD0w85ZfqYz+ZHlr5yo+3YUCfycWawU56T5ckWXsScsj5B8tqUcIG67DxXByo3VUgiAdA==" + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -783,6 +986,130 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, + "node_modules/sequelize": { + "version": "6.31.0", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.31.0.tgz", + "integrity": "sha512-nCPVtv+QydBmb3Us2jCNAr1Dx3gST83VZxxrUQn/JAVFCOrmYOgUaPUz5bevummyNf30zfHsZhIKYAOD3ULfTA==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/sequelize" + } + ], + "dependencies": { + "@types/debug": "^4.1.7", + "@types/validator": "^13.7.1", + "debug": "^4.3.3", + "dottie": "^2.0.2", + "inflection": "^1.13.2", + "lodash": "^4.17.21", + "moment": "^2.29.1", + "moment-timezone": "^0.5.35", + "pg-connection-string": "^2.5.0", + "retry-as-promised": "^7.0.3", + "semver": "^7.3.5", + "sequelize-pool": "^7.1.0", + "toposort-class": "^1.0.1", + "uuid": "^8.3.2", + "validator": "^13.7.0", + "wkx": "^0.5.0" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependenciesMeta": { + "ibm_db": { + "optional": true + }, + "mariadb": { + "optional": true + }, + "mysql2": { + "optional": true + }, + "oracledb": { + "optional": true + }, + "pg": { + "optional": true + }, + "pg-hstore": { + "optional": true + }, + "snowflake-sdk": { + "optional": true + }, + "sqlite3": { + "optional": true + }, + "tedious": { + "optional": true + } + } + }, + "node_modules/sequelize-auto": { + "version": "0.8.8", + "resolved": "https://registry.npmjs.org/sequelize-auto/-/sequelize-auto-0.8.8.tgz", + "integrity": "sha512-9o0qi2yMA86oFqcA5Nh14PnQSHP0E9WPEB4hP/NgxqdFE44Nq2u8Di5O3xmvWwXMIV6W+Q0YI/2VTLvlMJAjnQ==", + "dependencies": { + "lodash": "^4.17.21", + "mkdirp": "^1.0.4", + "reserved-words": "^0.1.2", + "yargs": "^16.2.0" + }, + "bin": { + "sequelize-auto": "bin/sequelize-auto" + }, + "engines": { + "node": ">= 10" + }, + "peerDependencies": { + "sequelize": ">3.30.0" + } + }, + "node_modules/sequelize-pool": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-7.1.0.tgz", + "integrity": "sha512-G9c0qlIWQSK29pR/5U2JF5dDQeqqHRragoyahj/Nx4KOOQ3CPPfzxnfqFPCSB7x5UgjOgnZ61nSxz+fjDpRlJg==", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/sequelize/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/sequelize/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/sequelize/node_modules/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", @@ -842,6 +1169,30 @@ "node": ">= 0.8" } }, + "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/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -872,6 +1223,11 @@ "node": ">=0.6" } }, + "node_modules/toposort-class": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz", + "integrity": "sha512-OsLcGGbYF3rMjPUf8oKktyvCiUxSbqMMS39m33MAjLTC1DVIH6x3WSt63/M77ihI09+Sdfk1AXvfhCEeUmC7mg==" + }, "node_modules/touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", @@ -916,6 +1272,22 @@ "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/validator": { + "version": "13.9.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.9.0.tgz", + "integrity": "sha512-B+dGG8U3fdtM0/aNK4/X8CXq/EcxU2WPrPEkJGslb47qyHsxmbggTWK0yEA4qnYVNF+nxNlN88o14hIcPmSIEA==", + "engines": { + "node": ">= 0.10" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -923,9 +1295,94 @@ "engines": { "node": ">= 0.8" } + }, + "node_modules/wkx": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/wkx/-/wkx-0.5.0.tgz", + "integrity": "sha512-Xng/d4Ichh8uN4l0FToV/258EjMGU9MGcA0HV2d9B/ZpZB3lqQm7nkOdZdm5GhKtLLhAE7PiVQwN4eN+2YJJUg==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "engines": { + "node": ">=10" + } } }, "dependencies": { + "@types/debug": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", + "integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==", + "requires": { + "@types/ms": "*" + } + }, + "@types/ms": { + "version": "0.7.31", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", + "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" + }, + "@types/node": { + "version": "18.16.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.3.tgz", + "integrity": "sha512-OPs5WnnT1xkCBiuQrZA4+YAV4HEJejmHneyraIaxsbev5yCEr6KMwINNFP9wQeFIw8FWcoTqF3vQsa5CDaI+8Q==" + }, + "@types/validator": { + "version": "13.7.15", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.15.tgz", + "integrity": "sha512-yeinDVQunb03AEP8luErFcyf/7Lf7AzKCD0NXfgVoGCCQDNpZET8Jgq74oBgqKld3hafLbfzt/3inUdQvaFeXQ==" + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -940,6 +1397,19 @@ "negotiator": "0.6.3" } }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, "anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -1029,6 +1499,29 @@ "readdirp": "~3.6.0" } }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1075,16 +1568,36 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" }, + "dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==" + }, + "dottie": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.3.tgz", + "integrity": "sha512-4liA0PuRkZWQFQjwBypdxPfZaRWiv5tkhMXY2hzsa2pNf5s7U3m9cwUchfNKe8wZQxdGPQQzO6Rm2uGe0rvohQ==" + }, "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==" }, + "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==" + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -1176,6 +1689,11 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, "get-intrinsic": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", @@ -1237,6 +1755,11 @@ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" }, + "inflection": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz", + "integrity": "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw==" + }, "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -1260,6 +1783,11 @@ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" }, + "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==" + }, "is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -1273,6 +1801,19 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -1314,6 +1855,24 @@ "brace-expansion": "^1.1.7" } }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" + }, + "moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" + }, + "moment-timezone": { + "version": "0.5.43", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz", + "integrity": "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==", + "requires": { + "moment": "^2.29.4" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -1382,6 +1941,11 @@ "ee-first": "1.1.1" } }, + "oracledb": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/oracledb/-/oracledb-5.5.0.tgz", + "integrity": "sha512-i5cPvMENpZP8nnqptB6l0pjiOyySj1IISkbM4Hr3yZEDdANo2eezarwZb9NQ8fTh5pRjmgpZdSyIbnn9N3AENw==" + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -1392,6 +1956,11 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, + "pg-connection-string": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz", + "integrity": "sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ==" + }, "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -1443,6 +2012,21 @@ "picomatch": "^2.2.1" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==" + }, + "reserved-words": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz", + "integrity": "sha512-0S5SrIUJ9LfpbVl4Yzij6VipUdafHrOTzvmfazSw/jeZrZtQK303OPZW+obtkaw7jQlTQppy0UvZWm9872PbRw==" + }, + "retry-as-promised": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.4.tgz", + "integrity": "sha512-XgmCoxKWkDofwH8WddD0w85ZfqYz+ZHlr5yo+3YUCfycWawU56T5ckWXsScsj5B8tqUcIG67DxXByo3VUgiAdA==" + }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1485,6 +2069,68 @@ } } }, + "sequelize": { + "version": "6.31.0", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.31.0.tgz", + "integrity": "sha512-nCPVtv+QydBmb3Us2jCNAr1Dx3gST83VZxxrUQn/JAVFCOrmYOgUaPUz5bevummyNf30zfHsZhIKYAOD3ULfTA==", + "requires": { + "@types/debug": "^4.1.7", + "@types/validator": "^13.7.1", + "debug": "^4.3.3", + "dottie": "^2.0.2", + "inflection": "^1.13.2", + "lodash": "^4.17.21", + "moment": "^2.29.1", + "moment-timezone": "^0.5.35", + "pg-connection-string": "^2.5.0", + "retry-as-promised": "^7.0.3", + "semver": "^7.3.5", + "sequelize-pool": "^7.1.0", + "toposort-class": "^1.0.1", + "uuid": "^8.3.2", + "validator": "^13.7.0", + "wkx": "^0.5.0" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "sequelize-auto": { + "version": "0.8.8", + "resolved": "https://registry.npmjs.org/sequelize-auto/-/sequelize-auto-0.8.8.tgz", + "integrity": "sha512-9o0qi2yMA86oFqcA5Nh14PnQSHP0E9WPEB4hP/NgxqdFE44Nq2u8Di5O3xmvWwXMIV6W+Q0YI/2VTLvlMJAjnQ==", + "requires": { + "lodash": "^4.17.21", + "mkdirp": "^1.0.4", + "reserved-words": "^0.1.2", + "yargs": "^16.2.0" + } + }, + "sequelize-pool": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-7.1.0.tgz", + "integrity": "sha512-G9c0qlIWQSK29pR/5U2JF5dDQeqqHRragoyahj/Nx4KOOQ3CPPfzxnfqFPCSB7x5UgjOgnZ61nSxz+fjDpRlJg==" + }, "serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", @@ -1531,6 +2177,24 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" }, + "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==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -1552,6 +2216,11 @@ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" }, + "toposort-class": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz", + "integrity": "sha512-OsLcGGbYF3rMjPUf8oKktyvCiUxSbqMMS39m33MAjLTC1DVIH6x3WSt63/M77ihI09+Sdfk1AXvfhCEeUmC7mg==" + }, "touch": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", @@ -1584,10 +2253,67 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==" }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + }, + "validator": { + "version": "13.9.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-13.9.0.tgz", + "integrity": "sha512-B+dGG8U3fdtM0/aNK4/X8CXq/EcxU2WPrPEkJGslb47qyHsxmbggTWK0yEA4qnYVNF+nxNlN88o14hIcPmSIEA==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" + }, + "wkx": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/wkx/-/wkx-0.5.0.tgz", + "integrity": "sha512-Xng/d4Ichh8uN4l0FToV/258EjMGU9MGcA0HV2d9B/ZpZB3lqQm7nkOdZdm5GhKtLLhAE7PiVQwN4eN+2YJJUg==", + "requires": { + "@types/node": "*" + } + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==" } } } diff --git a/server/package.json b/server/package.json index 80c93e7a5..97ab8d97e 100644 --- a/server/package.json +++ b/server/package.json @@ -14,7 +14,11 @@ "author": "", "license": "ISC", "dependencies": { + "dotenv": "^16.0.3", "express": "^4.18.2", - "nodemon": "^2.0.22" + "nodemon": "^2.0.22", + "oracledb": "^5.5.0", + "sequelize": "^6.31.0", + "sequelize-auto": "^0.8.8" } } diff --git a/server/src/config/README.md b/server/src/config/README.md new file mode 100644 index 000000000..40c95b2ed --- /dev/null +++ b/server/src/config/README.md @@ -0,0 +1 @@ +## CONFIG \ No newline at end of file diff --git a/server/src/controller/README.md b/server/src/controller/README.md new file mode 100644 index 000000000..e227ffbef --- /dev/null +++ b/server/src/controller/README.md @@ -0,0 +1 @@ +## CONTROLLER \ No newline at end of file diff --git a/server/src/models/README.md b/server/src/models/README.md new file mode 100644 index 000000000..7b5c6c909 --- /dev/null +++ b/server/src/models/README.md @@ -0,0 +1 @@ +## MODEL \ No newline at end of file diff --git a/server/src/routes/README.md b/server/src/routes/README.md new file mode 100644 index 000000000..778e0509a --- /dev/null +++ b/server/src/routes/README.md @@ -0,0 +1 @@ +## ROUTES \ No newline at end of file From 01b4b488cd264c174c9a3af620229b6f0ae6aba9 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 1 May 2023 19:26:02 +0900 Subject: [PATCH 05/70] =?UTF-8?q?-=20close=20#18=20DB=20=EC=97=B0=EB=8F=99?= =?UTF-8?q?,=20=EC=84=9C=EB=B2=84=20=ED=85=8C=EC=8A=A4=ED=8C=85=20?= =?UTF-8?q?=ED=9B=84=20=EB=B0=B0=ED=8F=AC=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/www.js | 24 ++++++++++++++++- server/src/config/sequelize.js | 28 +++++++++++++++++++ server/src/config/sequelizeAuto.js | 10 +++++++ server/src/models/index.js | 43 ++++++++++++++++++++++++++++++ server/src/models/test.js | 16 +++++++++++ 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 server/src/config/sequelize.js create mode 100644 server/src/config/sequelizeAuto.js create mode 100644 server/src/models/index.js create mode 100644 server/src/models/test.js diff --git a/server/bin/www.js b/server/bin/www.js index b9e6b5c69..d745e50a4 100644 --- a/server/bin/www.js +++ b/server/bin/www.js @@ -1,8 +1,30 @@ "use strict"; const app = require("../app"); +const models = require('../src/models/index.js'); const PORT = process.env.PORT || 3000; // 포트 -app.listen(PORT, () => { +const { auto } = require("../src/config/sequelizeAuto") + +const oracledb = require("oracledb") + +app.listen(PORT, async () => { + if (process.env.NODE_ENV == 'development') { // 현재 개발 환경이라면 + oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // oracle client 경로 수동 설정 + } + + try { + await models.sequelize.sync(); + } catch (err) { + console.log('DB 연결 중 오류 발생: ', err); + process.exit(); + } + + // // model auto generation test + // auto.run((err) => { + // if (err) throw err; + // console.log(auto.tables); // 생성된 모델 확인 + // }); + console.log(`Server running on port ${PORT}`); }); \ No newline at end of file diff --git a/server/src/config/sequelize.js b/server/src/config/sequelize.js new file mode 100644 index 000000000..139e9af7a --- /dev/null +++ b/server/src/config/sequelize.js @@ -0,0 +1,28 @@ +const development = { + dialect: 'oracle', + host: process.env.DB_HOST, + port: process.env.DB_PORT, + username: process.env.DB_USER, + password: process.env.DB_PASSWORD, + database: process.env.DB_DATABASE +} + +const production = { + dialect: 'oracle', + host: process.env.DB_HOST, + port: process.env.DB_PORT, + username: process.env.DB_USER, + password: process.env.DB_PASSWORD, + database: process.env.DB_DATABASE +} + +const test = { + dialect: 'oracle', + host: process.env.DB_HOST, + port: process.env.DB_PORT, + username: process.env.DB_USER, + password: process.env.DB_PASSWORD, + database: process.env.DB_DATABASE +} + +module.exports = { development, production, test } \ No newline at end of file diff --git a/server/src/config/sequelizeAuto.js b/server/src/config/sequelizeAuto.js new file mode 100644 index 000000000..6e4df4310 --- /dev/null +++ b/server/src/config/sequelizeAuto.js @@ -0,0 +1,10 @@ +const SequelizeAuto = require('sequelize-auto'); +const auto = new SequelizeAuto(process.env.DB_DATABASE, process.env.DB_USER, process.env.DB_PASSWORD, { + host: process.env.DB_HOST, + port: process.env.DB_PORT, + directory: "../models", // 모델 파일이 생성될 디렉토리 경로 + dialect: "oracle" +} +); + +module.exports = { auto }; \ No newline at end of file diff --git a/server/src/models/index.js b/server/src/models/index.js new file mode 100644 index 000000000..3dc28e97a --- /dev/null +++ b/server/src/models/index.js @@ -0,0 +1,43 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const Sequelize = require('sequelize'); +const process = require('process'); +const basename = path.basename(__filename); +const env = process.env.NODE_ENV || 'development'; +const config = require('../config/sequelize.js')[env]; +const db = {}; + +let sequelize; +if (config.use_env_variable) { + sequelize = new Sequelize(process.env[config.use_env_variable], config); +} else { + sequelize = new Sequelize(config.database, config.username, config.password, config); +} + +fs + .readdirSync(__dirname) + .filter(file => { + return ( + file.indexOf('.') !== 0 && + file !== basename && + file.slice(-3) === '.js' && + file.indexOf('.test.js') === -1 + ); + }) + .forEach(file => { + const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes); + db[model.name] = model; + }); + +Object.keys(db).forEach(modelName => { + if (db[modelName].associate) { + db[modelName].associate(db); + } +}); + +db.sequelize = sequelize; +db.Sequelize = Sequelize; + +module.exports = db; diff --git a/server/src/models/test.js b/server/src/models/test.js new file mode 100644 index 000000000..44f38acfa --- /dev/null +++ b/server/src/models/test.js @@ -0,0 +1,16 @@ +module.exports = (sequelize, DataTypes) => { + const User = sequelize.define('User', { + UserId: { + field: 'TEST', + type: DataTypes.STRING(32), + primaryKey: true, + allowNull: false, + defaultValue: '' + } + }, { + underscored: true, + freezeTableName: true, + tableName: 'DB_TEST' + }); + return User; +} \ No newline at end of file From 198194fa93b8e83fed08047c74d7bb008fd8e180 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 2 May 2023 14:09:51 +0900 Subject: [PATCH 06/70] =?UTF-8?q?#20=20sequelize=20model=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/models/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/models/test.js b/server/src/models/test.js index 44f38acfa..b371fbbe9 100644 --- a/server/src/models/test.js +++ b/server/src/models/test.js @@ -1,5 +1,5 @@ module.exports = (sequelize, DataTypes) => { - const User = sequelize.define('User', { + const User = sequelize.define('DB_TEST', { UserId: { field: 'TEST', type: DataTypes.STRING(32), From 6ee230107b8d66423bfb669d31e2286ae61fa28a Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 2 May 2023 15:08:23 +0900 Subject: [PATCH 07/70] =?UTF-8?q?#20=20user=20model=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/models/user.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 server/src/models/user.js diff --git a/server/src/models/user.js b/server/src/models/user.js new file mode 100644 index 000000000..299797ff1 --- /dev/null +++ b/server/src/models/user.js @@ -0,0 +1,32 @@ +module.exports = (sequelize, DataTypes) => { + const User = sequelize.define('User', { + UserId: { + field: 'ID', + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + defaultValue: 0, + }, + EMAIL: { + field: 'EMAIL', + type: DataTypes.INTEGER, + allowNull: false + }, + Password: { + field: 'PASSWORD', + type: DataTypes.STRING, + allowNull: false + }, + NICKNAME: { + field: 'NICKNAME', + type: DataTypes.STRING, + allowNull: false + } + }, { + underscored: true, + freezeTableName: true, + tableName: 'DB_USER', + timestamps: true, + }); + return User; +} \ No newline at end of file From e0ce2c79e1105d0ee11b0bb6bfc5524777b589aa Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 2 May 2023 16:43:37 +0900 Subject: [PATCH 08/70] =?UTF-8?q?#18=20user=20model=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=20=EC=8B=9C=20hook=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/models/user.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/src/models/user.js b/server/src/models/user.js index 299797ff1..683a07a99 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -1,5 +1,5 @@ module.exports = (sequelize, DataTypes) => { - const User = sequelize.define('User', { + return sequelize.define('User', { UserId: { field: 'ID', type: DataTypes.INTEGER, @@ -27,6 +27,14 @@ module.exports = (sequelize, DataTypes) => { freezeTableName: true, tableName: 'DB_USER', timestamps: true, + hooks: { + beforeCreate: async (user, options) => { + const result = await sequelize.query('SELECT USER_ID_SEQ.NEXTVAL AS ID FROM DUAL', { + type: sequelize.QueryTypes.SELECT + }); + // User 객체의 ID와 DB_USER의 ID 매핑 + user.UserId = result[0].ID; + }, + } }); - return User; } \ No newline at end of file From 04d9ef9fd41dc9e674ab40c2e4ac7aa05050eeb2 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 2 May 2023 22:00:26 +0900 Subject: [PATCH 09/70] =?UTF-8?q?#20=20model=20=ED=85=8C=EC=8A=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/README.md | 18 ++++ server/bin/www.js | 8 +- server/package-lock.json | 125 ++++++++++++++++++++++++ server/package.json | 1 + server/src/config/sequelize.js | 8 +- server/src/controller/user/user.ctrl.js | 28 ++++++ server/src/models/user.js | 2 +- server/src/routes/home/index.js | 6 +- server/src/routes/user/userRouter.js | 9 ++ 9 files changed, 200 insertions(+), 5 deletions(-) create mode 100644 server/README.md create mode 100644 server/src/controller/user/user.ctrl.js create mode 100644 server/src/routes/user/userRouter.js diff --git a/server/README.md b/server/README.md new file mode 100644 index 000000000..7b6e0e70d --- /dev/null +++ b/server/README.md @@ -0,0 +1,18 @@ + +``` +server +├─ .gitignore +├─ app.js +├─ bin +│ └─ www.js +├─ migrations +├─ package-lock.json +├─ package.json +├─ seeders +└─ src + ├─ config + ├─ controller + ├─ routes + └─ models + +``` \ No newline at end of file diff --git a/server/bin/www.js b/server/bin/www.js index d745e50a4..0ab7f7bdf 100644 --- a/server/bin/www.js +++ b/server/bin/www.js @@ -8,6 +8,7 @@ const { auto } = require("../src/config/sequelizeAuto") const oracledb = require("oracledb") + app.listen(PORT, async () => { if (process.env.NODE_ENV == 'development') { // 현재 개발 환경이라면 oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // oracle client 경로 수동 설정 @@ -19,7 +20,12 @@ app.listen(PORT, async () => { console.log('DB 연결 중 오류 발생: ', err); process.exit(); } - + + // Find all users + const users = await models.User.findAll(); + console.log(users.every(user => user instanceof User)); // true + console.log("All users:", JSON.stringify(users, null, 2)); + // // model auto generation test // auto.run((err) => { // if (err) throw err; diff --git a/server/package-lock.json b/server/package-lock.json index 3b8fab6d4..94a725633 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "dotenv": "^16.0.3", "express": "^4.18.2", + "jsonwebtoken": "^9.0.0", "nodemon": "^2.0.22", "oracledb": "^5.5.0", "sequelize": "^6.31.0", @@ -155,6 +156,11 @@ "node": ">=8" } }, + "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", @@ -302,6 +308,14 @@ "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.3.tgz", "integrity": "sha512-4liA0PuRkZWQFQjwBypdxPfZaRWiv5tkhMXY2hzsa2pNf5s7U3m9cwUchfNKe8wZQxdGPQQzO6Rm2uGe0rvohQ==" }, + "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", @@ -604,6 +618,59 @@ "node": ">=0.12.0" } }, + "node_modules/jsonwebtoken": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz", + "integrity": "sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw==", + "dependencies": { + "jws": "^3.2.2", + "lodash": "^4.17.21", + "ms": "^2.1.1", + "semver": "^7.3.8" + }, + "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/jsonwebtoken/node_modules/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "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/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -1470,6 +1537,11 @@ "fill-range": "^7.0.1" } }, + "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==" + }, "bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -1578,6 +1650,14 @@ "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.3.tgz", "integrity": "sha512-4liA0PuRkZWQFQjwBypdxPfZaRWiv5tkhMXY2hzsa2pNf5s7U3m9cwUchfNKe8wZQxdGPQQzO6Rm2uGe0rvohQ==" }, + "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==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -1801,6 +1881,51 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, + "jsonwebtoken": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz", + "integrity": "sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw==", + "requires": { + "jws": "^3.2.2", + "lodash": "^4.17.21", + "ms": "^2.1.1", + "semver": "^7.3.8" + }, + "dependencies": { + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "requires": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "requires": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", diff --git a/server/package.json b/server/package.json index 97ab8d97e..e277fc111 100644 --- a/server/package.json +++ b/server/package.json @@ -16,6 +16,7 @@ "dependencies": { "dotenv": "^16.0.3", "express": "^4.18.2", + "jsonwebtoken": "^9.0.0", "nodemon": "^2.0.22", "oracledb": "^5.5.0", "sequelize": "^6.31.0", diff --git a/server/src/config/sequelize.js b/server/src/config/sequelize.js index 139e9af7a..83a7ace78 100644 --- a/server/src/config/sequelize.js +++ b/server/src/config/sequelize.js @@ -4,7 +4,13 @@ const development = { port: process.env.DB_PORT, username: process.env.DB_USER, password: process.env.DB_PASSWORD, - database: process.env.DB_DATABASE + database: process.env.DB_DATABASE, + logging: console.log, + logQueryParameters: true, + define: { + timestamps: false + }, + quoteIdentifiers: false } const production = { diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js new file mode 100644 index 000000000..314e30d0a --- /dev/null +++ b/server/src/controller/user/user.ctrl.js @@ -0,0 +1,28 @@ +"use strict"; + +// GET +const output = { + +} + +// POST +const process = { + +} + +// PUT +const edit = { + +} + +// DELETE +const eliminate = { + +} + +module.exports = { + output, + process, + edit, + eliminate, +}; \ No newline at end of file diff --git a/server/src/models/user.js b/server/src/models/user.js index 683a07a99..97f9cdf30 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -9,7 +9,7 @@ module.exports = (sequelize, DataTypes) => { }, EMAIL: { field: 'EMAIL', - type: DataTypes.INTEGER, + type: DataTypes.STRING, allowNull: false }, Password: { diff --git a/server/src/routes/home/index.js b/server/src/routes/home/index.js index c6e16a718..4ebcb0cac 100644 --- a/server/src/routes/home/index.js +++ b/server/src/routes/home/index.js @@ -1,10 +1,12 @@ "use strict"; -const express = require("express"); -const router = express.Router(); +const router = require("express").Router(); router.get("/", (req, res) => { res.send("hello!"); }) +const user = require("../user/userRouter"); +router.use("/user", user); + module.exports = router; \ No newline at end of file diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js new file mode 100644 index 000000000..8a35a8fb4 --- /dev/null +++ b/server/src/routes/user/userRouter.js @@ -0,0 +1,9 @@ +"use strict"; + +const userCrtl = require('../../controller/user/user.ctrl'); + +const router = require("express").Router(); + +//router.post("/register", userCrtl.process) + +module.exports = router; \ No newline at end of file From b8b95c719cd80ba55c33842b6084b3e4183e0abe Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Thu, 4 May 2023 14:05:07 +0900 Subject: [PATCH 10/70] =?UTF-8?q?#22=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20api=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/www.js | 4 ++-- server/src/controller/user/user.ctrl.js | 4 +++- server/src/routes/user/userRouter.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/server/bin/www.js b/server/bin/www.js index 0ab7f7bdf..34c64565a 100644 --- a/server/bin/www.js +++ b/server/bin/www.js @@ -11,7 +11,7 @@ const oracledb = require("oracledb") app.listen(PORT, async () => { if (process.env.NODE_ENV == 'development') { // 현재 개발 환경이라면 - oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // oracle client 경로 수동 설정 + oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // 개발 머신에 따라 oracle client 경로 수동 설정 } try { @@ -23,7 +23,7 @@ app.listen(PORT, async () => { // Find all users const users = await models.User.findAll(); - console.log(users.every(user => user instanceof User)); // true + console.log(users.every(user => user instanceof models.User)); // true console.log("All users:", JSON.stringify(users, null, 2)); // // model auto generation test diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 314e30d0a..737cc34e9 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -7,7 +7,9 @@ const output = { // POST const process = { - + register: (req, res) => { + res.send("sign-up"); + } } // PUT diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index 8a35a8fb4..694a36b76 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -4,6 +4,6 @@ const userCrtl = require('../../controller/user/user.ctrl'); const router = require("express").Router(); -//router.post("/register", userCrtl.process) +router.post("/register", userCrtl.process.register) module.exports = router; \ No newline at end of file From 8daad885c67367cdf9d990fd19ae891230131249 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 8 May 2023 17:27:26 +0900 Subject: [PATCH 11/70] =?UTF-8?q?#37=20Refresh=20Token,=20Access=20Token?= =?UTF-8?q?=20=EB=B0=9C=EA=B8=89=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/README.md | 3 ++- server/src/config/jwt.js | 24 ++++++++++++++++++++++++ server/src/controller/user/user.ctrl.js | 4 +++- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 server/src/config/jwt.js diff --git a/server/README.md b/server/README.md index 7b6e0e70d..f2298b28d 100644 --- a/server/README.md +++ b/server/README.md @@ -13,6 +13,7 @@ server ├─ config ├─ controller ├─ routes - └─ models + ├─ models + └─ service ``` \ No newline at end of file diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js new file mode 100644 index 000000000..e73c129d5 --- /dev/null +++ b/server/src/config/jwt.js @@ -0,0 +1,24 @@ +const jwt = require('jsonwebtoken'); + +const AUTHORIZATION_HEADER = 'Authorization' + +// generate access token +const createAccessToken = (email) => { + return jwt.sign({ email }, process.env.JWT_ACCESS_TOKEN_SECRETKEY, { + expiresIn: "30m" + }) +} + +// generate refresh token +const createRefreshToken = (email) => { + return jwt.sign({ email }, process.env.JWT_REFRESH_TOKEN_SECRETKEY, { + expiresIn: "180d" + }) +} + + +module.exports = { + createAccessToken, + createRefreshToken, + +} \ No newline at end of file diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 737cc34e9..125a8294c 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -7,8 +7,10 @@ const output = { // POST const process = { + // Sign-up + // [POST] /user/register register: (req, res) => { - res.send("sign-up"); + } } From 73a07741c1bda25fdbbed4982ed39422d57081e9 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 8 May 2023 17:51:52 +0900 Subject: [PATCH 12/70] =?UTF-8?q?close=20#37=20Refresh=20token,=20Access?= =?UTF-8?q?=20token=20=EA=B2=80=EC=A6=9D=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 6 ++++++ server/src/config/jwt.js | 45 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..98eaac6a8 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "2023_1_WAP_APP_TEAM_MEDI", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index e73c129d5..6ce7f1305 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -16,9 +16,52 @@ const createRefreshToken = (email) => { }) } +// resolve token +const resolveToken = (req) => { + const token = req.header[AUTHORIZATION_HEADER] // extract token from http header + if (token && token.startsWith("Bearer ")) { // if token exist + return token.substring(7); // return pure token value + } + return null; +} + +// verifying access token +const verifyAccessToken = (req, res, next) => { + const token = resolveToken(req); // parsing token + if (token) { // if token does not exist + console.log("token is empty or sent format is wrong") + return res.sendStatus(401); // 401 unauthorized + } + jwt.verify(token, process.env.JWT_ACCESS_TOKEN_SECRETKEY, (err, data) => { // verifing token + if (err) { + console.log(err) + res.sendStatus(403); // 403 forbidden + } + req.verifiedToken = data; + next(); + }) +} + +// verifying refresh token +const verifyRefreshToken = (req, res, next) => { + const token = resolveToken(req); // parsing token + if (token) { // if token does not exist + console.log("token is empty or sent format is wrong") + return res.sendStatus(401); // 401 unauthorized + } + jwt.verify(token, process.env.JWT_REFRESH_TOKEN_SECRETKEY, (err, data) => { // verifing token + if (err) { + console.log(err) + res.sendStatus(403); // 403 forbidden + } + req.verifiedToken = data; + next(); + }) +} module.exports = { createAccessToken, createRefreshToken, - + verifyAccessToken, + verifyRefreshToken } \ No newline at end of file From b99312df3dc214f0b284c7213e981136c0e1279c Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 8 May 2023 18:16:53 +0900 Subject: [PATCH 13/70] closed #37 close issue --- server/src/config/jwt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index 6ce7f1305..140c13fde 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -52,7 +52,7 @@ const verifyRefreshToken = (req, res, next) => { jwt.verify(token, process.env.JWT_REFRESH_TOKEN_SECRETKEY, (err, data) => { // verifing token if (err) { console.log(err) - res.sendStatus(403); // 403 forbidden + res.sendStatus(403); // 403 forbidden } req.verifiedToken = data; next(); From 7505479a83df659117aac06f5633f98cded8ccc4 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 9 May 2023 14:22:34 +0900 Subject: [PATCH 14/70] =?UTF-8?q?#22=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app.js | 2 + server/package-lock.json | 102 ++++++++++++++++++++---- server/package.json | 1 + server/src/config/jwt.js | 8 +- server/src/config/responseMsg.js | 16 ++++ server/src/controller/user/user.ctrl.js | 12 ++- server/src/models/user.js | 9 +-- server/src/service/userService.js | 61 ++++++++++++++ 8 files changed, 184 insertions(+), 27 deletions(-) create mode 100644 server/src/config/responseMsg.js create mode 100644 server/src/service/userService.js diff --git a/server/app.js b/server/app.js index 588f2a18c..3c9aae320 100644 --- a/server/app.js +++ b/server/app.js @@ -3,6 +3,7 @@ // 모듈 const express = require("express"); const app = express(); +const bodyParser = require('body-parser'); const dotenv = require("dotenv"); dotenv.config(); @@ -10,6 +11,7 @@ dotenv.config(); const home = require("./src/routes/home"); // 미들웨어 +app.use(bodyParser.json()); app.use("/", home); module.exports = app; \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json index 94a725633..c02982b9f 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "body-parser": "^1.20.2", "dotenv": "^16.0.3", "express": "^4.18.2", "jsonwebtoken": "^9.0.0", @@ -114,12 +115,12 @@ } }, "node_modules/body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dependencies": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -127,7 +128,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" }, @@ -396,6 +397,43 @@ "node": ">= 0.10.0" } }, + "node_modules/express/node_modules/body-parser": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/express/node_modules/raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -951,9 +989,9 @@ } }, "node_modules/raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "dependencies": { "bytes": "3.1.2", "http-errors": "2.0.0", @@ -1502,12 +1540,12 @@ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" }, "body-parser": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", - "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "requires": { "bytes": "3.1.2", - "content-type": "~1.0.4", + "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "1.2.0", @@ -1515,7 +1553,7 @@ "iconv-lite": "0.4.24", "on-finished": "2.4.1", "qs": "6.11.0", - "raw-body": "2.5.1", + "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" } @@ -1724,6 +1762,38 @@ "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" + }, + "dependencies": { + "body-parser": { + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", + "requires": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + } + }, + "raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "requires": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + } } }, "fill-range": { @@ -2119,9 +2189,9 @@ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" }, "raw-body": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", - "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", "requires": { "bytes": "3.1.2", "http-errors": "2.0.0", diff --git a/server/package.json b/server/package.json index e277fc111..1f3c84637 100644 --- a/server/package.json +++ b/server/package.json @@ -14,6 +14,7 @@ "author": "", "license": "ISC", "dependencies": { + "body-parser": "^1.20.2", "dotenv": "^16.0.3", "express": "^4.18.2", "jsonwebtoken": "^9.0.0", diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index 140c13fde..e34155083 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -3,15 +3,15 @@ const jwt = require('jsonwebtoken'); const AUTHORIZATION_HEADER = 'Authorization' // generate access token -const createAccessToken = (email) => { - return jwt.sign({ email }, process.env.JWT_ACCESS_TOKEN_SECRETKEY, { +const createAccessToken = (email, nickname) => { + return jwt.sign({ email, nickname }, process.env.JWT_ACCESS_TOKEN_SECRETKEY, { expiresIn: "30m" }) } // generate refresh token -const createRefreshToken = (email) => { - return jwt.sign({ email }, process.env.JWT_REFRESH_TOKEN_SECRETKEY, { +const createRefreshToken = (email, nickname) => { + return jwt.sign({ email, nickname }, process.env.JWT_REFRESH_TOKEN_SECRETKEY, { expiresIn: "180d" }) } diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js new file mode 100644 index 000000000..5fdb4131a --- /dev/null +++ b/server/src/config/responseMsg.js @@ -0,0 +1,16 @@ +"use strict"; + +module.exports = { + // Success + SIGNUP_SUCCESS: { message: "new user created" }, + + // Request error + SIGNUP_BAD_REQUEST: { message: "paramter must include 'email(string), password(string), nickname(string)'" }, + + // Response error + SIGNUP_DUPLICATE_PARAMETER: (parameter) => { + return { message: `the ${parameter} is already in use` } + }, + SIGNUP_INTERNAL_SERVER_ERROR: { message: "DB Error" } + +} \ No newline at end of file diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 125a8294c..941b1ec76 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -1,5 +1,8 @@ "use strict"; +const responseMsg = require("../../config/responseMsg"); +const { createUser } = require("../../service/userService"); + // GET const output = { @@ -9,8 +12,13 @@ const output = { const process = { // Sign-up // [POST] /user/register - register: (req, res) => { - + register: async (req, res) => { + const { email, password, nickname } = req.body; + if (!(email && password && nickname)) { + res.status(400).send(responseMsg.SIGNUP_BAD_REQUEST); + } + const result = await createUser(email, password, nickname); // create user + return res.status(result.code).send(result.response); } } diff --git a/server/src/models/user.js b/server/src/models/user.js index 97f9cdf30..ecaae80c9 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -1,6 +1,6 @@ module.exports = (sequelize, DataTypes) => { return sequelize.define('User', { - UserId: { + USERID: { field: 'ID', type: DataTypes.INTEGER, primaryKey: true, @@ -12,7 +12,7 @@ module.exports = (sequelize, DataTypes) => { type: DataTypes.STRING, allowNull: false }, - Password: { + PASSWORD: { field: 'PASSWORD', type: DataTypes.STRING, allowNull: false @@ -28,12 +28,11 @@ module.exports = (sequelize, DataTypes) => { tableName: 'DB_USER', timestamps: true, hooks: { - beforeCreate: async (user, options) => { + beforeCreate: async (user, options) => { // sequence to user id mapping const result = await sequelize.query('SELECT USER_ID_SEQ.NEXTVAL AS ID FROM DUAL', { type: sequelize.QueryTypes.SELECT }); - // User 객체의 ID와 DB_USER의 ID 매핑 - user.UserId = result[0].ID; + user.USERID = result[0].ID; // User 객체의 ID와 DB_USER의 ID 매핑 }, } }); diff --git a/server/src/service/userService.js b/server/src/service/userService.js new file mode 100644 index 000000000..c2be81eef --- /dev/null +++ b/server/src/service/userService.js @@ -0,0 +1,61 @@ +"use strict"; + +const { User } = require("../models/index"); +const responseMsg = require("../config/responseMsg"); +const { createAccessToken, createRefreshToken } = require("../config/jwt"); + +// duplicate check +const duplicateCheck = async (parameter) => { + if ((await User.findAll({ // if user not exists + where: parameter + })).length == 0) { + return false; + } + return true; // if user exists +} + +// create user +const createUser = async (email, password, nickname) => { + // duplicate check + let checkParam = "EMAIL" + if (await duplicateCheck({ [checkParam]: email })) { // email + return { + code: 409, + response: responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam) + }; + } + checkParam = "NICKNAME"; + if (await duplicateCheck({ [checkParam]: nickname })) { // nickname + return { + code: 409, + response: responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam) + }; + } + + try { + const user = await models.User.create({ // insert new User into DB + EMAIL: email, + Password: password, + NICKNAME: nickname + }); + const response = responseMsg.SIGNUP_SUCCESS; + response.accessToken = createAccessToken(user.EMAIL, user.NICKNAME); // generate access token + response.refreshToken = createRefreshToken(user.EMAIL, user.NICKNAME); // generate refresh token + + return { + code: 201, + response + }; + } + catch (err) { + console.log(err); + return { + code: 500, + response: responseMsg.SIGNUP_INTERNAL_SERVER_ERROR + }; + } +} + +module.exports = { + createUser +} \ No newline at end of file From 227ca0253b14ad46a8087d8e42ff6418be23d0ac Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 9 May 2023 14:44:05 +0900 Subject: [PATCH 15/70] =?UTF-8?q?#22=20=ED=86=A0=ED=81=B0=20payload?= =?UTF-8?q?=EC=97=90=20=EC=9C=A0=EC=A0=80=20id=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=ED=8F=AC=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/jwt.js | 8 ++++---- server/src/service/userService.js | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index e34155083..b5918f218 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -3,15 +3,15 @@ const jwt = require('jsonwebtoken'); const AUTHORIZATION_HEADER = 'Authorization' // generate access token -const createAccessToken = (email, nickname) => { - return jwt.sign({ email, nickname }, process.env.JWT_ACCESS_TOKEN_SECRETKEY, { +const createAccessToken = (userId, email, nickname) => { + return jwt.sign({ userId, email, nickname }, process.env.JWT_ACCESS_TOKEN_SECRETKEY, { expiresIn: "30m" }) } // generate refresh token -const createRefreshToken = (email, nickname) => { - return jwt.sign({ email, nickname }, process.env.JWT_REFRESH_TOKEN_SECRETKEY, { +const createRefreshToken = (userId, email, nickname) => { + return jwt.sign({ userId, email, nickname }, process.env.JWT_REFRESH_TOKEN_SECRETKEY, { expiresIn: "180d" }) } diff --git a/server/src/service/userService.js b/server/src/service/userService.js index c2be81eef..0f71155df 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -33,14 +33,15 @@ const createUser = async (email, password, nickname) => { } try { - const user = await models.User.create({ // insert new User into DB + const user = await User.create({ // insert new User into DB EMAIL: email, - Password: password, + PASSWORD: password, NICKNAME: nickname }); + console.log(user) const response = responseMsg.SIGNUP_SUCCESS; - response.accessToken = createAccessToken(user.EMAIL, user.NICKNAME); // generate access token - response.refreshToken = createRefreshToken(user.EMAIL, user.NICKNAME); // generate refresh token + response.accessToken = createAccessToken(user.USERID, user.EMAIL, user.NICKNAME); // generate access token + response.refreshToken = createRefreshToken(user.USERID, user.EMAIL, user.NICKNAME); // generate refresh token return { code: 201, From e03acce037e5ddd3bcde52b3df99ddeaf8acd5bd Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 13:58:10 +0900 Subject: [PATCH 16/70] =?UTF-8?q?#21=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20api?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/user/user.ctrl.js | 16 +++++++++++++--- server/src/routes/user/userRouter.js | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 941b1ec76..b6a79878b 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -1,20 +1,30 @@ "use strict"; const responseMsg = require("../../config/responseMsg"); -const { createUser } = require("../../service/userService"); +const { login, createUser } = require("../../service/userService"); // GET const output = { - + // } // POST const process = { + // Sign-in + // [POST] /user/login + login: async (req, res) => { + const { email, password } = req.body; + if (!(email, password)) { // parameter check + res.status(400).send(responseMsg.SIGNIN_BAD_REQUEST); + } + const result = await login(email, password); + return res.status(result.code).send(result.response); + }, // Sign-up // [POST] /user/register register: async (req, res) => { const { email, password, nickname } = req.body; - if (!(email && password && nickname)) { + if (!(email && password && nickname)) { // parameter check res.status(400).send(responseMsg.SIGNUP_BAD_REQUEST); } const result = await createUser(email, password, nickname); // create user diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index 694a36b76..f91728fa1 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -4,6 +4,8 @@ const userCrtl = require('../../controller/user/user.ctrl'); const router = require("express").Router(); -router.post("/register", userCrtl.process.register) +router.post("/login", userCrtl.process.login); // sign-in +//router.head("/refresh", userCrtl.output) +router.post("/register", userCrtl.process.register); // sign-up module.exports = router; \ No newline at end of file From 82c54c4c877ac207845aa210b2c6bc184fc98e1d Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 14:22:00 +0900 Subject: [PATCH 17/70] =?UTF-8?q?#21=20response=20format=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/response.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 server/src/config/response.js diff --git a/server/src/config/response.js b/server/src/config/response.js new file mode 100644 index 000000000..6c8680b87 --- /dev/null +++ b/server/src/config/response.js @@ -0,0 +1,10 @@ +"use strict"; + +module.exports = { + response: (code, message) => { + return { + code, + message + } + } +} \ No newline at end of file From b46c7970b5e2b89abc611c86500b4185fa8b2886 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 14:39:50 +0900 Subject: [PATCH 18/70] =?UTF-8?q?#37=20JWT=20payload=20=EA=B5=AC=EC=A1=B0?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/jwt.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index b5918f218..b6f4804f9 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -1,17 +1,19 @@ -const jwt = require('jsonwebtoken'); +"use strict"; +const jwt = require('jsonwebtoken'); +const responseMsg = require("./responseMsg"); const AUTHORIZATION_HEADER = 'Authorization' // generate access token -const createAccessToken = (userId, email, nickname) => { - return jwt.sign({ userId, email, nickname }, process.env.JWT_ACCESS_TOKEN_SECRETKEY, { +const createAccessToken = (userId) => { + return jwt.sign({ userId }, process.env.JWT_ACCESS_TOKEN_SECRETKEY, { expiresIn: "30m" }) } // generate refresh token -const createRefreshToken = (userId, email, nickname) => { - return jwt.sign({ userId, email, nickname }, process.env.JWT_REFRESH_TOKEN_SECRETKEY, { +const createRefreshToken = (userId) => { + return jwt.sign({ userId }, process.env.JWT_REFRESH_TOKEN_SECRETKEY, { expiresIn: "180d" }) } @@ -29,13 +31,12 @@ const resolveToken = (req) => { const verifyAccessToken = (req, res, next) => { const token = resolveToken(req); // parsing token if (token) { // if token does not exist - console.log("token is empty or sent format is wrong") - return res.sendStatus(401); // 401 unauthorized + return res.sendStatus(401).send(responseMsg.JWT_INVALID_FORMAT); // 401 unauthorized } jwt.verify(token, process.env.JWT_ACCESS_TOKEN_SECRETKEY, (err, data) => { // verifing token if (err) { console.log(err) - res.sendStatus(403); // 403 forbidden + res.sendStatus(401).send(err); // 401 unauthorized } req.verifiedToken = data; next(); @@ -46,13 +47,12 @@ const verifyAccessToken = (req, res, next) => { const verifyRefreshToken = (req, res, next) => { const token = resolveToken(req); // parsing token if (token) { // if token does not exist - console.log("token is empty or sent format is wrong") - return res.sendStatus(401); // 401 unauthorized + return res.sendStatus(401).send(responseMsg.JWT_INVALID_FORMAT); // 401 unauthorized } jwt.verify(token, process.env.JWT_REFRESH_TOKEN_SECRETKEY, (err, data) => { // verifing token if (err) { console.log(err) - res.sendStatus(403); // 403 forbidden + res.sendStatus(401).send(err); // 401 unauthorized } req.verifiedToken = data; next(); From c01608283b66576f3a45f4a68e5546f0218b4333 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 14:48:21 +0900 Subject: [PATCH 19/70] =?UTF-8?q?#22=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/response.js | 4 +-- server/src/config/responseMsg.js | 5 +++ server/src/models/user.js | 6 ++-- server/src/service/userService.js | 56 ++++++++++++++++++------------- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/server/src/config/response.js b/server/src/config/response.js index 6c8680b87..1f39ea964 100644 --- a/server/src/config/response.js +++ b/server/src/config/response.js @@ -1,10 +1,10 @@ "use strict"; module.exports = { - response: (code, message) => { + response: (code, response) => { return { code, - message + response } } } \ No newline at end of file diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 5fdb4131a..0a3f7d705 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -2,9 +2,14 @@ module.exports = { // Success + SIGNIN_SUCCESS: { message: "login success" }, SIGNUP_SUCCESS: { message: "new user created" }, // Request error + JWT_INVALID_FORMAT: { message: "token is empty or sent format is wrong" }, + SIGNIN_BAD_REQUEST: { message: "paramter must include 'email(string), password(string)'" }, + SIGNIN_USER_NOT_FOUND: { message: "user not found" }, + SIGNIN_PASSWORD_MISMATCH: { message: "password mismatch" }, SIGNUP_BAD_REQUEST: { message: "paramter must include 'email(string), password(string), nickname(string)'" }, // Response error diff --git a/server/src/models/user.js b/server/src/models/user.js index ecaae80c9..1696acd32 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -10,7 +10,8 @@ module.exports = (sequelize, DataTypes) => { EMAIL: { field: 'EMAIL', type: DataTypes.STRING, - allowNull: false + allowNull: false, + unique: true }, PASSWORD: { field: 'PASSWORD', @@ -20,7 +21,8 @@ module.exports = (sequelize, DataTypes) => { NICKNAME: { field: 'NICKNAME', type: DataTypes.STRING, - allowNull: false + allowNull: false, + unique: true } }, { underscored: true, diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 0f71155df..0653c16ca 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -1,17 +1,39 @@ "use strict"; const { User } = require("../models/index"); +const { response } = require("../config/response"); const responseMsg = require("../config/responseMsg"); const { createAccessToken, createRefreshToken } = require("../config/jwt"); +// sign-in +const login = async (email, password) => { + const userInfo = await User.findOne({ + attributes: ["USERID", "PASSWORD"], + where: { + EMAIL: email + } + }); + if (!userInfo) { // if user not exists + return response(404, responseMsg.SIGNIN_USER_NOT_FOUND); + } + if (password != userInfo.PASSWORD) { // password mismatch + return response(401, responseMsg.SIGNIN_PASSWORD_MISMATCH); + } + const response = responseMsg.SIGNIN_SUCCESS; + response.accessToken = createAccessToken(userInfo.USERID); // generate access token + response.refreshToken = createRefreshToken(userInfo.USERID); // generate refresh token + + return response(200, response); +} + // duplicate check const duplicateCheck = async (parameter) => { - if ((await User.findAll({ // if user not exists + if (await User.findOne({ // if user exists where: parameter - })).length == 0) { - return false; + })) { + return true; } - return true; // if user exists + return false; // if user not exists } // create user @@ -19,17 +41,11 @@ const createUser = async (email, password, nickname) => { // duplicate check let checkParam = "EMAIL" if (await duplicateCheck({ [checkParam]: email })) { // email - return { - code: 409, - response: responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam) - }; + return response(409, responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam)); } checkParam = "NICKNAME"; if (await duplicateCheck({ [checkParam]: nickname })) { // nickname - return { - code: 409, - response: responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam) - }; + return response(409, responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam)); } try { @@ -38,25 +54,19 @@ const createUser = async (email, password, nickname) => { PASSWORD: password, NICKNAME: nickname }); - console.log(user) const response = responseMsg.SIGNUP_SUCCESS; - response.accessToken = createAccessToken(user.USERID, user.EMAIL, user.NICKNAME); // generate access token - response.refreshToken = createRefreshToken(user.USERID, user.EMAIL, user.NICKNAME); // generate refresh token + response.accessToken = createAccessToken(user.USERID); // generate access token + response.refreshToken = createRefreshToken(user.USERID); // generate refresh token - return { - code: 201, - response - }; + return response(201, response); } catch (err) { console.log(err); - return { - code: 500, - response: responseMsg.SIGNUP_INTERNAL_SERVER_ERROR - }; + return response(500, responseMsg.SIGNUP_INTERNAL_SERVER_ERROR); } } module.exports = { + login, createUser } \ No newline at end of file From 6c2e23d3f60f051a2f86fe27226f431a4244be44 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 14:49:25 +0900 Subject: [PATCH 20/70] =?UTF-8?q?#21=20response=20format=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/response.js | 2 +- server/src/controller/user/user.ctrl.js | 9 ++++++--- server/src/service/userService.js | 16 ++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/server/src/config/response.js b/server/src/config/response.js index 1f39ea964..de535e366 100644 --- a/server/src/config/response.js +++ b/server/src/config/response.js @@ -1,7 +1,7 @@ "use strict"; module.exports = { - response: (code, response) => { + responseFormat: (code, response) => { return { code, response diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index b6a79878b..b4a21c69c 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -1,5 +1,6 @@ "use strict"; +const { responseFormat } = require("../../config/response") const responseMsg = require("../../config/responseMsg"); const { login, createUser } = require("../../service/userService"); @@ -15,9 +16,10 @@ const process = { login: async (req, res) => { const { email, password } = req.body; if (!(email, password)) { // parameter check - res.status(400).send(responseMsg.SIGNIN_BAD_REQUEST); + const result = responseFormat(400, responseMsg.SIGNIN_BAD_REQUEST); + return res.status(result.code).send(result.response); } - const result = await login(email, password); + const result = await login(email, password); // access to account return res.status(result.code).send(result.response); }, // Sign-up @@ -25,7 +27,8 @@ const process = { register: async (req, res) => { const { email, password, nickname } = req.body; if (!(email && password && nickname)) { // parameter check - res.status(400).send(responseMsg.SIGNUP_BAD_REQUEST); + const result = responseFormat(400, responseMsg.SIGNUP_BAD_REQUEST); + return res.status(result.code).send(result.response); } const result = await createUser(email, password, nickname); // create user return res.status(result.code).send(result.response); diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 0653c16ca..62588ca44 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -1,7 +1,7 @@ "use strict"; const { User } = require("../models/index"); -const { response } = require("../config/response"); +const { responseFormat } = require("../config/response"); const responseMsg = require("../config/responseMsg"); const { createAccessToken, createRefreshToken } = require("../config/jwt"); @@ -14,16 +14,16 @@ const login = async (email, password) => { } }); if (!userInfo) { // if user not exists - return response(404, responseMsg.SIGNIN_USER_NOT_FOUND); + return responseFormat(404, responseMsg.SIGNIN_USER_NOT_FOUND); } if (password != userInfo.PASSWORD) { // password mismatch - return response(401, responseMsg.SIGNIN_PASSWORD_MISMATCH); + return responseFormat(401, responseMsg.SIGNIN_PASSWORD_MISMATCH); } const response = responseMsg.SIGNIN_SUCCESS; response.accessToken = createAccessToken(userInfo.USERID); // generate access token response.refreshToken = createRefreshToken(userInfo.USERID); // generate refresh token - return response(200, response); + return responseFormat(200, response); } // duplicate check @@ -41,11 +41,11 @@ const createUser = async (email, password, nickname) => { // duplicate check let checkParam = "EMAIL" if (await duplicateCheck({ [checkParam]: email })) { // email - return response(409, responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam)); + return responseFormat(409, responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam)); } checkParam = "NICKNAME"; if (await duplicateCheck({ [checkParam]: nickname })) { // nickname - return response(409, responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam)); + return responseFormat(409, responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam)); } try { @@ -58,11 +58,11 @@ const createUser = async (email, password, nickname) => { response.accessToken = createAccessToken(user.USERID); // generate access token response.refreshToken = createRefreshToken(user.USERID); // generate refresh token - return response(201, response); + return responseFormat(201, response); } catch (err) { console.log(err); - return response(500, responseMsg.SIGNUP_INTERNAL_SERVER_ERROR); + return responseFormat(500, responseMsg.SIGNUP_INTERNAL_SERVER_ERROR); } } From 939847eed9f2725baa78607611ea10dbaef492c7 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 15:09:44 +0900 Subject: [PATCH 21/70] =?UTF-8?q?#21=20user=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20login=20=ED=95=A8=EC=88=98=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/user/user.ctrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index b4a21c69c..9f3612e8f 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -15,7 +15,7 @@ const process = { // [POST] /user/login login: async (req, res) => { const { email, password } = req.body; - if (!(email, password)) { // parameter check + if (!(email && password)) { // parameter check const result = responseFormat(400, responseMsg.SIGNIN_BAD_REQUEST); return res.status(result.code).send(result.response); } From 238815a345a3efaaa7dd95171e6bd72ee8578dfd Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 16:22:10 +0900 Subject: [PATCH 22/70] =?UTF-8?q?#37=20=ED=86=A0=ED=81=B0=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=ED=95=A8=EC=88=98=20=EB=B0=98=ED=99=98=EA=B0=92=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/jwt.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index b6f4804f9..03c459faf 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -1,8 +1,9 @@ "use strict"; const jwt = require('jsonwebtoken'); +const { responseFormat } = require("./response") const responseMsg = require("./responseMsg"); -const AUTHORIZATION_HEADER = 'Authorization' +const AUTHORIZATION_HEADER = 'authorization' // generate access token const createAccessToken = (userId) => { @@ -20,7 +21,9 @@ const createRefreshToken = (userId) => { // resolve token const resolveToken = (req) => { - const token = req.header[AUTHORIZATION_HEADER] // extract token from http header + console.log(req.headers) + const token = req.headers[AUTHORIZATION_HEADER] // extract token from http header + console.log(token) if (token && token.startsWith("Bearer ")) { // if token exist return token.substring(7); // return pure token value } @@ -30,13 +33,15 @@ const resolveToken = (req) => { // verifying access token const verifyAccessToken = (req, res, next) => { const token = resolveToken(req); // parsing token - if (token) { // if token does not exist - return res.sendStatus(401).send(responseMsg.JWT_INVALID_FORMAT); // 401 unauthorized + if (!token) { // if token does not exist + const result = responseFormat(401, responseMsg.JWT_INVALID_FORMAT); // 401 unauthorized + return res.status(result.code).send(result.response); } jwt.verify(token, process.env.JWT_ACCESS_TOKEN_SECRETKEY, (err, data) => { // verifing token if (err) { console.log(err) - res.sendStatus(401).send(err); // 401 unauthorized + const result = responseFormat(401, { message: err.message }); // 401 unauthorized + return res.status(result.code).send(result.response); } req.verifiedToken = data; next(); @@ -46,13 +51,15 @@ const verifyAccessToken = (req, res, next) => { // verifying refresh token const verifyRefreshToken = (req, res, next) => { const token = resolveToken(req); // parsing token - if (token) { // if token does not exist - return res.sendStatus(401).send(responseMsg.JWT_INVALID_FORMAT); // 401 unauthorized + if (!token) { // if token does not exist + const result = responseFormat(401, responseMsg.JWT_INVALID_FORMAT); // 401 unauthorized + return res.status(result.code).send(result.response); } jwt.verify(token, process.env.JWT_REFRESH_TOKEN_SECRETKEY, (err, data) => { // verifing token if (err) { console.log(err) - res.sendStatus(401).send(err); // 401 unauthorized + const result = responseFormat(401, { message: err.message }); // 401 unauthorized + return res.status(result.code).send(result.response); } req.verifiedToken = data; next(); From 47131eb522c7bacb7184c9ade34d6344d4398eb1 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 16:24:42 +0900 Subject: [PATCH 23/70] =?UTF-8?q?#43=20=ED=86=A0=ED=81=B0=20=EC=9E=AC?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20API=20=EC=83=9D=EC=84=B1,=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 1 + server/src/controller/user/user.ctrl.js | 10 ++++++++-- server/src/routes/user/userRouter.js | 4 ++-- server/src/service/userService.js | 11 ++++++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 0a3f7d705..0da7b2c0f 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -4,6 +4,7 @@ module.exports = { // Success SIGNIN_SUCCESS: { message: "login success" }, SIGNUP_SUCCESS: { message: "new user created" }, + REISSUE_SUCCESS: { message: "reissued tokens" }, // Request error JWT_INVALID_FORMAT: { message: "token is empty or sent format is wrong" }, diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 9f3612e8f..21217d80b 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -2,11 +2,10 @@ const { responseFormat } = require("../../config/response") const responseMsg = require("../../config/responseMsg"); -const { login, createUser } = require("../../service/userService"); +const { login, createUser, reissueToken } = require("../../service/userService"); // GET const output = { - // } // POST @@ -32,6 +31,13 @@ const process = { } const result = await createUser(email, password, nickname); // create user return res.status(result.code).send(result.response); + }, + // Reissuing token + // [POST] /user/reissue + reissue: (req, res) => { + const { userId } = req.verifiedToken; + const result = reissueToken(userId); // reissuing token + return res.status(result.code).send(result.response); } } diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index f91728fa1..98b583c85 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -1,11 +1,11 @@ "use strict"; const userCrtl = require('../../controller/user/user.ctrl'); - +const { verifyRefreshToken } = require("../../config/jwt"); const router = require("express").Router(); router.post("/login", userCrtl.process.login); // sign-in -//router.head("/refresh", userCrtl.output) +router.post("/reissue", verifyRefreshToken, userCrtl.process.reissue); // reissuing token router.post("/register", userCrtl.process.register); // sign-up module.exports = router; \ No newline at end of file diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 62588ca44..59fcea5c7 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -66,7 +66,16 @@ const createUser = async (email, password, nickname) => { } } +// reissue token +const reissueToken = (userId) => { + const response = responseMsg.REISSUE_SUCCESS; + response.accessToken = createAccessToken(userId); // generate access token + response.refreshToken = createRefreshToken(userId); // generate refresh token + return responseFormat(200, response); +} + module.exports = { login, - createUser + createUser, + reissueToken } \ No newline at end of file From 751bc2012096eefdbc477c99123b656effd08d59 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 10 May 2023 20:59:54 +0900 Subject: [PATCH 24/70] =?UTF-8?q?#20=20Sequelize=20model,=20hook=20?= =?UTF-8?q?=EC=A0=95=EC=9D=98=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/www.js | 7 +++- server/src/models/comment.js | 47 +++++++++++++++++++++++++++ server/src/models/favoriteMedicine.js | 36 ++++++++++++++++++++ server/src/models/like.js | 35 ++++++++++++++++++++ server/src/models/medicine.js | 47 +++++++++++++++++++++++++++ server/src/models/recentBrowsed.js | 36 ++++++++++++++++++++ server/src/models/test.js | 16 --------- server/src/models/user.js | 17 ++++++---- 8 files changed, 217 insertions(+), 24 deletions(-) create mode 100644 server/src/models/comment.js create mode 100644 server/src/models/favoriteMedicine.js create mode 100644 server/src/models/like.js create mode 100644 server/src/models/medicine.js create mode 100644 server/src/models/recentBrowsed.js delete mode 100644 server/src/models/test.js diff --git a/server/bin/www.js b/server/bin/www.js index 0ab7f7bdf..2f346e698 100644 --- a/server/bin/www.js +++ b/server/bin/www.js @@ -23,8 +23,13 @@ app.listen(PORT, async () => { // Find all users const users = await models.User.findAll(); - console.log(users.every(user => user instanceof User)); // true + console.log(users.every(user => user instanceof models.User)); // true console.log("All users:", JSON.stringify(users, null, 2)); + console.log("All medicines:", JSON.stringify(await models.Medicine.findAll(), null, 2)); + console.log("All likes:", JSON.stringify(await models.Like.findAll(), null, 2)); + console.log("All comments:", JSON.stringify(await models.Comment.findAll(), null, 2)); + console.log("All recent browses:", JSON.stringify(await models.RecentBrowsed.findAll(), null, 2)); + console.log("All favorite medicines:", JSON.stringify(await models.FavoriteMedicine.findAll(), null, 2)); // // model auto generation test // auto.run((err) => { diff --git a/server/src/models/comment.js b/server/src/models/comment.js new file mode 100644 index 000000000..f2b77f600 --- /dev/null +++ b/server/src/models/comment.js @@ -0,0 +1,47 @@ +"use strict"; + +module.exports = (sequelize, DataTypes) => { + return sequelize.define('Comment', { + ID: { + field: 'ID', + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + defaultValue: 0, + }, + USERID: { + field: 'USER_ID', + type: DataTypes.INTEGER, + allowNull: false + }, + MEDICINEID: { + field: 'MEDICINE_ID', + type: DataTypes.INTEGER, + allowNull: false + }, + SUBORDINATION: { + field: 'SUBORDINATION', + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: 0 + }, + CONTENT: { + field: 'CONTENT', + type: DataTypes.STRING, + allowNull: false + } + }, { + underscored: true, + freezeTableName: true, + tableName: 'DB_COMMENT', + timestamps: true, + hooks: { + beforeCreate: async (comment, options) => { // sequence to comment id mapping + const result = await sequelize.query('SELECT COMMENT_ID_SEQ.NEXTVAL AS ID FROM DUAL', { + type: sequelize.QueryTypes.SELECT + }); + comment.ID = result[0].ID; // comment 객체의 ID와 DB_comment의 ID 매핑 + }, + } + }); +} \ No newline at end of file diff --git a/server/src/models/favoriteMedicine.js b/server/src/models/favoriteMedicine.js new file mode 100644 index 000000000..9e950f5cc --- /dev/null +++ b/server/src/models/favoriteMedicine.js @@ -0,0 +1,36 @@ +"use strict"; + +module.exports = (sequelize, DataTypes) => { + return sequelize.define('FavoriteMedicine', { + ID: { + field: 'ID', + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + defaultValue: 0, + }, + USERID: { + field: 'USER_ID', + type: DataTypes.INTEGER, + allowNull: false + }, + MEDICINEID: { + field: 'MEDICINE_ID', + type: DataTypes.INTEGER, + allowNull: false + } + }, { + underscored: true, + freezeTableName: true, + tableName: 'DB_FAVORITE_MEDICINE', + timestamps: true, + hooks: { + beforeCreate: async (data, options) => { // sequence to data id mapping + const result = await sequelize.query('SELECT FAVORITE_MEDICINE_ID_SEQ.NEXTVAL AS ID FROM DUAL', { + type: sequelize.QueryTypes.SELECT + }); + data.ID = result[0].ID; // data 객체의 ID와 DB_FAVORITE_MEDICINE의 ID 매핑 + }, + } + }); +} \ No newline at end of file diff --git a/server/src/models/like.js b/server/src/models/like.js new file mode 100644 index 000000000..d530f7132 --- /dev/null +++ b/server/src/models/like.js @@ -0,0 +1,35 @@ +"use strict"; + +module.exports = (sequelize, DataTypes) => { + return sequelize.define('Like', { + ID: { + field: 'ID', + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + defaultValue: 0, + }, + USERID: { + field: 'USER_ID', + type: DataTypes.INTEGER, + allowNull: false + }, + COMMENTID: { + field: 'COMMENT_ID', + type: DataTypes.INTEGER, + allowNull: false + } + }, { + underscored: true, + freezeTableName: true, + tableName: 'DB_LIKE', + hooks: { + beforeCreate: async (data, options) => { // sequence to data id mapping + const result = await sequelize.query('SELECT LIKE_ID_SEQ.NEXTVAL AS ID FROM DUAL', { + type: sequelize.QueryTypes.SELECT + }); + data.ID = result[0].ID; // data 객체의 ID와 DB_LIKE의 ID 매핑 + }, + } + }); +} \ No newline at end of file diff --git a/server/src/models/medicine.js b/server/src/models/medicine.js new file mode 100644 index 000000000..245973c0b --- /dev/null +++ b/server/src/models/medicine.js @@ -0,0 +1,47 @@ +"use strict"; + +module.exports = (sequelize, DataTypes) => { + return sequelize.define('Medicine', { + ITEM_SEQ: { + field: 'ITEM_SEQ', + type: DataTypes.STRING, + primaryKey: true, + allowNull: false, + defaultValue: 0, + }, + ITEM_NAME: { + field: 'ITEM_NAME', + type: DataTypes.STRING, + allowNull: false + }, + ITEM_INGR_NAME: { + field: 'ITEM_INGR_NAME', + type: DataTypes.STRING, + allowNull: false + }, + PRDUCT_TYPE: { + field: 'PRDUCT_TYPE', + type: DataTypes.STRING, + allowNull: false + }, + ENTP_NAME: { + field: 'ENTP_NAME', + type: DataTypes.STRING, + allowNull: false + }, + SPCLTY_PBLC: { + field: 'SPCLTY_PBLC', + type: DataTypes.STRING, + allowNull: false + }, + INGREDIENT_NAME: { + field: 'INGREDIENT_NAME', + type: DataTypes.STRING, + allowNull: false + } + }, { + underscored: true, + freezeTableName: true, + tableName: 'DB_MEDICINE' + }); +} \ No newline at end of file diff --git a/server/src/models/recentBrowsed.js b/server/src/models/recentBrowsed.js new file mode 100644 index 000000000..2b47828ce --- /dev/null +++ b/server/src/models/recentBrowsed.js @@ -0,0 +1,36 @@ +"use strict"; + +module.exports = (sequelize, DataTypes) => { + return sequelize.define('RecentBrowsed', { + ID: { + field: 'ID', + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + defaultValue: 0, + }, + USERID: { + field: 'USER_ID', + type: DataTypes.INTEGER, + allowNull: false + }, + QUERY: { + field: 'QUERY', + type: DataTypes.STRING, + allowNull: false + } + }, { + underscored: true, + freezeTableName: true, + tableName: 'DB_RECENT_BROWSED', + timestamps: true, + hooks: { + beforeCreate: async (data, options) => { // sequence to data id mapping + const result = await sequelize.query('SELECT RECENT_BROWSED_SEQ.NEXTVAL AS ID FROM DUAL', { + type: sequelize.QueryTypes.SELECT + }); + data.ID = result[0].ID; // data 객체의 ID와 DB_RECENT_BROWSED의 ID 매핑 + }, + } + }); +} \ No newline at end of file diff --git a/server/src/models/test.js b/server/src/models/test.js deleted file mode 100644 index b371fbbe9..000000000 --- a/server/src/models/test.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = (sequelize, DataTypes) => { - const User = sequelize.define('DB_TEST', { - UserId: { - field: 'TEST', - type: DataTypes.STRING(32), - primaryKey: true, - allowNull: false, - defaultValue: '' - } - }, { - underscored: true, - freezeTableName: true, - tableName: 'DB_TEST' - }); - return User; -} \ No newline at end of file diff --git a/server/src/models/user.js b/server/src/models/user.js index 97f9cdf30..5e4187502 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -1,6 +1,8 @@ +"use strict"; + module.exports = (sequelize, DataTypes) => { return sequelize.define('User', { - UserId: { + USERID: { field: 'ID', type: DataTypes.INTEGER, primaryKey: true, @@ -10,9 +12,10 @@ module.exports = (sequelize, DataTypes) => { EMAIL: { field: 'EMAIL', type: DataTypes.STRING, - allowNull: false + allowNull: false, + unique: true }, - Password: { + PASSWORD: { field: 'PASSWORD', type: DataTypes.STRING, allowNull: false @@ -20,7 +23,8 @@ module.exports = (sequelize, DataTypes) => { NICKNAME: { field: 'NICKNAME', type: DataTypes.STRING, - allowNull: false + allowNull: false, + unique: true } }, { underscored: true, @@ -28,12 +32,11 @@ module.exports = (sequelize, DataTypes) => { tableName: 'DB_USER', timestamps: true, hooks: { - beforeCreate: async (user, options) => { + beforeCreate: async (user, options) => { // sequence to user id mapping const result = await sequelize.query('SELECT USER_ID_SEQ.NEXTVAL AS ID FROM DUAL', { type: sequelize.QueryTypes.SELECT }); - // User 객체의 ID와 DB_USER의 ID 매핑 - user.UserId = result[0].ID; + user.USERID = result[0].ID; // User 객체의 ID와 DB_USER의 ID 매핑 }, } }); From 1d46943218f3c9c8fca80e6388f3d2ac441c18e1 Mon Sep 17 00:00:00 2001 From: winocreative Date: Sun, 21 May 2023 20:59:47 +0900 Subject: [PATCH 25/70] =?UTF-8?q?DB=20=EC=97=B0=EA=B4=80=EC=84=B1=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EC=9D=BC=EB=B6=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes .idea/.gitignore | 8 +++++++ .idea/misc.xml | 6 ++++++ .vscode/launch.json | 30 ++++++++++++++++++++++++++ server/.DS_Store | Bin 0 -> 6148 bytes server/src/.DS_Store | Bin 0 -> 6148 bytes server/src/models/comment.js | 10 +++++++-- server/src/models/favoriteMedicine.js | 16 +++++++++----- server/src/models/like.js | 13 +++++++---- server/src/models/medicine.js | 28 +++++++++++++++++++----- server/src/models/recentBrowsed.js | 13 +++++++---- server/src/models/user.js | 15 +++++++++---- server/src/service/userService.js | 10 ++++----- 13 files changed, 120 insertions(+), 29 deletions(-) create mode 100644 .DS_Store create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .vscode/launch.json create mode 100644 server/.DS_Store create mode 100644 server/src/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..76a74b5b0fdee4c8e796ecc6181619937dbae579 GIT binary patch literal 6148 zcmeHK%}T>S5T317Q$(ns;Bmog)%sJhc!^aHUXAEMr6x9LG-gZF+CwSitPkVWC-HT3 zW_PR9sz)g@12f<3>`apVHtY`oh+3zy22cb52bC~aK=X}IKk10%Y$T5;^fP?8h7gt^ z1~rn+fpKJj=57v};KLQ%q5YgcYOla8q&Sz!VXUr#SOu6(zsfG^%9|GS0H!c2gcdxI z{gV6qTW-)zoA$XcK{JlhcDej2aufN8`bsNe!G*_{MH$@j+Kgof$s+= zQP`~)=l4|7_M;?h>4K;cV#@hxlr&VgraDO@)wQ1Ka0*VLUR><;DwXY$tdy($lI&I2 z%O$zFvDNPvoQ0*;oum3)e4nUCJwg!phijR&IDjW~hQ|NkwUSsR*BBqv400Kn0cL<1 z7!L;Q>g3Ff$LH`@FaylM7%@QWgG42CEoKJw(t$=_0TAgJsReyHAX1IA=vvGSVh@Ti zrHH0f*eixGAQAsE-Gx$-0j^2tfm$u?XR4o{n + + + + + \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..f2746e86f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,30 @@ +{ + // IntelliSense를 사용하여 가능한 특성에 대해 알아보세요. + // 기존 특성에 대한 설명을 보려면 가리킵니다. + // 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요. + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "서버 실행 - 기본값", + "skipFiles": [ + "/**" + ], + "cwd": "${workspaceFolder}/server", + "program": "${workspaceFolder}/server/bin/www.js" + }, + + { + "type": "node", + "request": "launch", + "name": "서버 실행 - 재완 맥북", + "skipFiles": [ + "/**" + ], + "cwd": "${workspaceFolder}/server", + "program": "${workspaceFolder}/server/bin/www.js", + "runtimeExecutable": "${env:HOME}/.nvm/versions/node/v14.21.3/bin/node" + } + ] +} \ No newline at end of file diff --git a/server/.DS_Store b/server/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5c797a504a7540a0c810e36495ef24d0eff10fb4 GIT binary patch literal 6148 zcmeHK%Z}496uoZCOv(&WkwBUaQY1DkN+~cM7_kYZvtYqyf?xrtBuzDh$;4ID(nVD% zYxo$pd;y=pzp#RHZI6_sR6;`HCEvR-K%vHXOWET@j>1HSYu>iODqt1(+Z5onyF~#_@as@{{qm;p5UKM`nR@j)g%nd- zSmo^XvEsE$DM^ZGOhYL0g^O%rc9l=zB#EWvFq+s?ML z8iA+!6!~DyLMnEGvMScR^ZbCh&>MBMkS0W&8fc3c$r`^g3n|Scxciz!f7nlq$rrDHg7`vYqA-Me-RQ zrq@16--Q#*%uc1+DOFDhm7Qq!Tkp7pt=M*>H0Q!@=y6Ru>t4oAQd_}2)~v)hI#7|7rY)Sq9P6kcO_@{5DN`iA6|kfSHX zPYn5$XP!J~4Nn`6F*m}@6pDJTdUR86I4@3QE;$cR(xfN{gA28`-n!TBcpY!kI}E;> zc~DNuSuvXA2Xyq_m^8d>Pr?sLJRkQSyfIlhNwPR+LlVW9^66ueMP@!Svn(pu8`uG_ z>vhMyt;J$EeAU;(!OpU;7dy`eef{G3%jL4`J$$^q`)>R#Jvk5%!a(%^YV?BAq51@?K@%fr4nmDgI7Vh#Mq--kg0$ST-0mXd(g^wRz}0Y{)tVBH?}X#L;+^ZvhXaz~DU zBXFk(sMcPvH^N(zwRPp@Xsy*)K4YPvyvizDu#)AN8?+Q}Vd20rO$}6Ew6cml816-Y MF}TVR_^Skd1Hkyo?*IS* literal 0 HcmV?d00001 diff --git a/server/src/models/comment.js b/server/src/models/comment.js index f2b77f600..8f4d38a8d 100644 --- a/server/src/models/comment.js +++ b/server/src/models/comment.js @@ -1,7 +1,7 @@ "use strict"; -module.exports = (sequelize, DataTypes) => { - return sequelize.define('Comment', { +module.exports = function (sequelize, DataTypes) { + const Comment = sequelize.define('Comment', { ID: { field: 'ID', type: DataTypes.INTEGER, @@ -44,4 +44,10 @@ module.exports = (sequelize, DataTypes) => { }, } }); + + Comment.associate = function (models) { + Comment.belongsTo(models.User, {foreignKey: 'USERID', sourceKey: 'ID'}); + Comment.hasMany(models.Like, {foreignKey: 'COMMENTID', targetKey: 'ID'}); + } + return Comment; } \ No newline at end of file diff --git a/server/src/models/favoriteMedicine.js b/server/src/models/favoriteMedicine.js index 9e950f5cc..c18ac149a 100644 --- a/server/src/models/favoriteMedicine.js +++ b/server/src/models/favoriteMedicine.js @@ -1,7 +1,7 @@ "use strict"; -module.exports = (sequelize, DataTypes) => { - return sequelize.define('FavoriteMedicine', { +module.exports = function (sequelize, DataTypes) { + const FavoriteMedicine = sequelize.define('FavoriteMedicine', { ID: { field: 'ID', type: DataTypes.INTEGER, @@ -25,12 +25,18 @@ module.exports = (sequelize, DataTypes) => { tableName: 'DB_FAVORITE_MEDICINE', timestamps: true, hooks: { - beforeCreate: async (data, options) => { // sequence to data id mapping + beforeCreate: async (favoriteMedicine, options) => { // sequence to data id mapping const result = await sequelize.query('SELECT FAVORITE_MEDICINE_ID_SEQ.NEXTVAL AS ID FROM DUAL', { type: sequelize.QueryTypes.SELECT }); - data.ID = result[0].ID; // data 객체의 ID와 DB_FAVORITE_MEDICINE의 ID 매핑 + favoriteMedicine.ID = result[0].ID; // data 객체의 ID와 DB_FAVORITE_MEDICINE의 ID 매핑 }, } }); -} \ No newline at end of file + + FavoriteMedicine.associate = function (models) { + FavoriteMedicine.belongsTo(models.User, {foreignKey: 'USERID', sourceKey: 'ID'}); + FavoriteMedicine.belongsTo(models.Medicine, {foreignKey: 'MEDICINEID', sourceKey: 'ID'}); + } + return FavoriteMedicine; +} diff --git a/server/src/models/like.js b/server/src/models/like.js index d530f7132..24ed598bc 100644 --- a/server/src/models/like.js +++ b/server/src/models/like.js @@ -1,7 +1,7 @@ "use strict"; -module.exports = (sequelize, DataTypes) => { - return sequelize.define('Like', { +module.exports = function (sequelize, DataTypes) { + const Like = sequelize.define('Like', { ID: { field: 'ID', type: DataTypes.INTEGER, @@ -24,12 +24,17 @@ module.exports = (sequelize, DataTypes) => { freezeTableName: true, tableName: 'DB_LIKE', hooks: { - beforeCreate: async (data, options) => { // sequence to data id mapping + beforeCreate: async (like, options) => { // sequence to data id mapping const result = await sequelize.query('SELECT LIKE_ID_SEQ.NEXTVAL AS ID FROM DUAL', { type: sequelize.QueryTypes.SELECT }); - data.ID = result[0].ID; // data 객체의 ID와 DB_LIKE의 ID 매핑 + like.ID = result[0].ID; // data 객체의 ID와 DB_LIKE의 ID 매핑 }, } }); + Like.associate = function (models) { + Like.belongsTo(models.User, {foreignKey: 'USERID', sourceKey: 'ID'}); + Like.belongsTo(models.Comment, {foreignKey: 'COMMENTID', sourceKey: 'ID'}); + } + return Like; } \ No newline at end of file diff --git a/server/src/models/medicine.js b/server/src/models/medicine.js index 245973c0b..e90fc4ee4 100644 --- a/server/src/models/medicine.js +++ b/server/src/models/medicine.js @@ -1,13 +1,18 @@ "use strict"; -module.exports = (sequelize, DataTypes) => { - return sequelize.define('Medicine', { +module.exports = function (sequelize, DataTypes) { + const Medicine = sequelize.define('Medicine', { + ID: { + field: 'ID', + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + defaultValue: 0 + }, ITEM_SEQ: { field: 'ITEM_SEQ', type: DataTypes.STRING, - primaryKey: true, allowNull: false, - defaultValue: 0, }, ITEM_NAME: { field: 'ITEM_NAME', @@ -42,6 +47,19 @@ module.exports = (sequelize, DataTypes) => { }, { underscored: true, freezeTableName: true, - tableName: 'DB_MEDICINE' + tableName: 'DB_MEDICINE', + hooks: { + beforeCreate: async (medicine, options) => { // sequence to user id mapping + const result = await sequelize.query('SELECT MEDICINE_SEQ.NEXTVAL AS ID FROM DUAL', { + type: sequelize.QueryTypes.SELECT + }); + medicine.ID = result[0].ID; // User 객체의 ID와 DB_USER의 ID 매핑 + }, + } }); + Medicine.associate = function (models) { + Medicine.hasMany(models.FavoriteMedicine, {foreignKey: 'MEDICINEID', targetKey: 'ID'}); + Medicine.hasMany(models.Comment, {foreignKey: 'MEDICINEID', targetKey: 'ID'}); + } + return Medicine; } \ No newline at end of file diff --git a/server/src/models/recentBrowsed.js b/server/src/models/recentBrowsed.js index 2b47828ce..9db1b9b0a 100644 --- a/server/src/models/recentBrowsed.js +++ b/server/src/models/recentBrowsed.js @@ -1,7 +1,7 @@ "use strict"; -module.exports = (sequelize, DataTypes) => { - return sequelize.define('RecentBrowsed', { +module.exports = function (sequelize, DataTypes) { + const RecentBrowsed = sequelize.define('RecentBrowsed', { ID: { field: 'ID', type: DataTypes.INTEGER, @@ -25,12 +25,17 @@ module.exports = (sequelize, DataTypes) => { tableName: 'DB_RECENT_BROWSED', timestamps: true, hooks: { - beforeCreate: async (data, options) => { // sequence to data id mapping + beforeCreate: async (recentBrowsed, options) => { // sequence to data id mapping const result = await sequelize.query('SELECT RECENT_BROWSED_SEQ.NEXTVAL AS ID FROM DUAL', { type: sequelize.QueryTypes.SELECT }); - data.ID = result[0].ID; // data 객체의 ID와 DB_RECENT_BROWSED의 ID 매핑 + recentBrowsed.ID = result[0].ID; // data 객체의 ID와 DB_RECENT_BROWSED의 ID 매핑 }, } }); + + RecentBrowsed.associate = function (models) { + RecentBrowsed.belongsTo(models.User, {foreignKey: 'USERID', sourceKey: 'ID'}); + } + return RecentBrowsed; } \ No newline at end of file diff --git a/server/src/models/user.js b/server/src/models/user.js index 5e4187502..2c341d042 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -1,8 +1,8 @@ "use strict"; -module.exports = (sequelize, DataTypes) => { - return sequelize.define('User', { - USERID: { +module.exports = function (sequelize, DataTypes) { + const User = sequelize.define('User', { + ID: { field: 'ID', type: DataTypes.INTEGER, primaryKey: true, @@ -36,8 +36,15 @@ module.exports = (sequelize, DataTypes) => { const result = await sequelize.query('SELECT USER_ID_SEQ.NEXTVAL AS ID FROM DUAL', { type: sequelize.QueryTypes.SELECT }); - user.USERID = result[0].ID; // User 객체의 ID와 DB_USER의 ID 매핑 + user.ID = result[0].ID; // User 객체의 ID와 DB_USER의 ID 매핑 }, } }); + User.associate = function (models) { + User.hasMany(models.RecentBrowsed, {foreignKey: 'USERID', targetKey: 'ID'}); + User.hasMany(models.FavoriteMedicine, {foreignKey: 'USERID', targetKey: 'ID'}); + User.hasMany(models.Like, {foreignKey: 'USERID', targetKey: 'ID'}); + User.hasMany(models.Comment, {foreignKey: 'USERID', targetKey: 'ID'}); + } + return User; } \ No newline at end of file diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 59fcea5c7..e8c7e7f2b 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -8,7 +8,7 @@ const { createAccessToken, createRefreshToken } = require("../config/jwt"); // sign-in const login = async (email, password) => { const userInfo = await User.findOne({ - attributes: ["USERID", "PASSWORD"], + attributes: ["ID", "PASSWORD"], where: { EMAIL: email } @@ -20,8 +20,8 @@ const login = async (email, password) => { return responseFormat(401, responseMsg.SIGNIN_PASSWORD_MISMATCH); } const response = responseMsg.SIGNIN_SUCCESS; - response.accessToken = createAccessToken(userInfo.USERID); // generate access token - response.refreshToken = createRefreshToken(userInfo.USERID); // generate refresh token + response.accessToken = createAccessToken(userInfo.ID); // generate access token + response.refreshToken = createRefreshToken(userInfo.ID); // generate refresh token return responseFormat(200, response); } @@ -55,8 +55,8 @@ const createUser = async (email, password, nickname) => { NICKNAME: nickname }); const response = responseMsg.SIGNUP_SUCCESS; - response.accessToken = createAccessToken(user.USERID); // generate access token - response.refreshToken = createRefreshToken(user.USERID); // generate refresh token + response.accessToken = createAccessToken(user.ID); // generate access token + response.refreshToken = createRefreshToken(user.ID); // generate refresh token return responseFormat(201, response); } From d2bc9823761730fb45bbfa6a7791873aa091113b Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 23 May 2023 21:48:22 +0900 Subject: [PATCH 26/70] =?UTF-8?q?#78=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20API?= =?UTF-8?q?=20=EB=AA=85=EC=84=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app.js | 8 +- server/package-lock.json | 524 +++++++++++++++++++++++++++ server/package.json | 4 + server/src/routes/home/index.js | 6 + server/src/routes/user/userRouter.js | 72 ++++ server/swagger/swagger.js | 23 ++ 6 files changed, 636 insertions(+), 1 deletion(-) create mode 100644 server/swagger/swagger.js diff --git a/server/app.js b/server/app.js index 3c9aae320..707af7c79 100644 --- a/server/app.js +++ b/server/app.js @@ -6,12 +6,18 @@ const app = express(); const bodyParser = require('body-parser'); const dotenv = require("dotenv"); dotenv.config(); +const { swaggerUi, specs } = require("./swagger/swagger"); // swagger // 라우팅 const home = require("./src/routes/home"); // 미들웨어 -app.use(bodyParser.json()); +// app.use(bodyParser.json()); +app.use(express.json()) // 내장 body-parser +app.use(express.urlencoded({ extended: true })) + app.use("/", home); +app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs)) + module.exports = app; \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json index c02982b9f..f79730942 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -20,8 +20,62 @@ }, "bin": { "server": "www.js" + }, + "devDependencies": { + "swagger-jsdoc": "^6.2.8", + "swagger-ui-express": "^4.6.3" + } + }, + "node_modules/@apidevtools/json-schema-ref-parser": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.1.2.tgz", + "integrity": "sha512-r1w81DpR+KyRWd3f+rk6TNqMgedmAxZP5v5KWlXQWlgMUUtyEJch0DKEci1SorPMiSeM8XPl7MZ3miJ60JIpQg==", + "dev": true, + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" } }, + "node_modules/@apidevtools/openapi-schemas": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@apidevtools/openapi-schemas/-/openapi-schemas-2.1.0.tgz", + "integrity": "sha512-Zc1AlqrJlX3SlpupFGpiLi2EbteyP7fXmUOGup6/DnkRgjP9bgMM/ag+n91rsv0U1Gpz0H3VILA/o3bW7Ua6BQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@apidevtools/swagger-methods": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@apidevtools/swagger-methods/-/swagger-methods-3.0.2.tgz", + "integrity": "sha512-QAkD5kK2b1WfjDS/UQn/qQkbwF31uqRjPTrsCs5ZG9BQGAkjwvqGFjjPqAuzac/IYzpPtRzjCP1WrTuAIjMrXg==", + "dev": true + }, + "node_modules/@apidevtools/swagger-parser": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/@apidevtools/swagger-parser/-/swagger-parser-10.0.3.tgz", + "integrity": "sha512-sNiLY51vZOmSPFZA5TF35KZ2HbgYklQnTSDnkghamzLb3EkNtcQnrBQEj5AOCxHpTtXpqMCRM1CrmV2rG6nw4g==", + "dev": true, + "dependencies": { + "@apidevtools/json-schema-ref-parser": "^9.0.6", + "@apidevtools/openapi-schemas": "^2.0.4", + "@apidevtools/swagger-methods": "^3.0.2", + "@jsdevtools/ono": "^7.1.3", + "call-me-maybe": "^1.0.1", + "z-schema": "^5.0.1" + }, + "peerDependencies": { + "openapi-types": ">=7" + } + }, + "node_modules/@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", + "dev": true + }, "node_modules/@types/debug": { "version": "4.1.7", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", @@ -30,6 +84,12 @@ "@types/ms": "*" } }, + "node_modules/@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, "node_modules/@types/ms": { "version": "0.7.31", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", @@ -96,6 +156,12 @@ "node": ">= 8" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -182,6 +248,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/call-me-maybe": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==", + "dev": true + }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -234,6 +306,15 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/commander": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.0.tgz", + "integrity": "sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -296,6 +377,18 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/dotenv": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", @@ -348,6 +441,15 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -478,6 +580,12 @@ "node": ">= 0.6" } }, + "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==", + "dev": true + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -517,6 +625,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "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", @@ -597,6 +725,16 @@ "node >= 0.4.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==", + "dev": true, + "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", @@ -656,6 +794,18 @@ "node": ">=0.12.0" } }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/jsonwebtoken": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz", @@ -714,6 +864,24 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "dev": true + }, + "node_modules/lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", + "dev": true + }, + "node_modules/lodash.mergewith": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz", + "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==", + "dev": true + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -911,6 +1079,22 @@ "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==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/openapi-types": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.0.tgz", + "integrity": "sha512-XpeCy01X6L5EpP+6Hc3jWN7rMZJ+/k1lwki/kTmWzbVhdPie3jd5O2ZtedEx8Yp58icJ0osVldLMrTB/zslQXA==", + "dev": true, + "peer": true + }, "node_modules/oracledb": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/oracledb/-/oracledb-5.5.0.tgz", @@ -928,6 +1112,15 @@ "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==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", @@ -1309,6 +1502,59 @@ "node": ">=4" } }, + "node_modules/swagger-jsdoc": { + "version": "6.2.8", + "resolved": "https://registry.npmjs.org/swagger-jsdoc/-/swagger-jsdoc-6.2.8.tgz", + "integrity": "sha512-VPvil1+JRpmJ55CgAtn8DIcpBs0bL5L3q5bVQvF4tAW/k/9JYSj7dCpaYCAv5rufe0vcCbBRQXGvzpkWjvLklQ==", + "dev": true, + "dependencies": { + "commander": "6.2.0", + "doctrine": "3.0.0", + "glob": "7.1.6", + "lodash.mergewith": "^4.6.2", + "swagger-parser": "^10.0.3", + "yaml": "2.0.0-1" + }, + "bin": { + "swagger-jsdoc": "bin/swagger-jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/swagger-parser": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/swagger-parser/-/swagger-parser-10.0.3.tgz", + "integrity": "sha512-nF7oMeL4KypldrQhac8RyHerJeGPD1p2xDh900GPvc+Nk7nWP6jX2FcC7WmkinMoAmoO774+AFXcWsW8gMWEIg==", + "dev": true, + "dependencies": { + "@apidevtools/swagger-parser": "10.0.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/swagger-ui-dist": { + "version": "4.18.3", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-4.18.3.tgz", + "integrity": "sha512-QW280Uvt234+TLo9NMPRa2Sj17RoorbQlR2eEY4R6Cs0LbdXhiO14YWX9OPBkBdiN64GQYz4zU8wlHLVi81lBg==", + "dev": true + }, + "node_modules/swagger-ui-express": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-4.6.3.tgz", + "integrity": "sha512-CDje4PndhTD2HkgyKH3pab+LKspDeB/NhPN2OF1j+piYIamQqBYwAXWESOT1Yju2xFg51bRW9sUng2WxDjzArw==", + "dev": true, + "dependencies": { + "swagger-ui-dist": ">=4.11.0" + }, + "engines": { + "node": ">= v0.10.32" + }, + "peerDependencies": { + "express": ">=4.0.0 || >=5.0.0-beta" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -1425,6 +1671,12 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "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==", + "dev": true + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -1438,6 +1690,15 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, + "node_modules/yaml": { + "version": "2.0.0-1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-1.tgz", + "integrity": "sha512-W7h5dEhywMKenDJh2iX/LABkbFnBxasD27oyXWDS/feDsxiw0dD5ncXdYXgkvAsXIY2MpW/ZKkr9IU30DBdMNQ==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -1462,9 +1723,83 @@ "engines": { "node": ">=10" } + }, + "node_modules/z-schema": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-5.0.5.tgz", + "integrity": "sha512-D7eujBWkLa3p2sIpJA0d1pr7es+a7m0vFAnZLlCEKq/Ij2k0MLi9Br2UPxoxdYystm5K1yeBGzub0FlYUEWj2Q==", + "dev": true, + "dependencies": { + "lodash.get": "^4.4.2", + "lodash.isequal": "^4.5.0", + "validator": "^13.7.0" + }, + "bin": { + "z-schema": "bin/z-schema" + }, + "engines": { + "node": ">=8.0.0" + }, + "optionalDependencies": { + "commander": "^9.4.1" + } + }, + "node_modules/z-schema/node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "dev": true, + "optional": true, + "engines": { + "node": "^12.20.0 || >=14" + } } }, "dependencies": { + "@apidevtools/json-schema-ref-parser": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.1.2.tgz", + "integrity": "sha512-r1w81DpR+KyRWd3f+rk6TNqMgedmAxZP5v5KWlXQWlgMUUtyEJch0DKEci1SorPMiSeM8XPl7MZ3miJ60JIpQg==", + "dev": true, + "requires": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" + } + }, + "@apidevtools/openapi-schemas": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@apidevtools/openapi-schemas/-/openapi-schemas-2.1.0.tgz", + "integrity": "sha512-Zc1AlqrJlX3SlpupFGpiLi2EbteyP7fXmUOGup6/DnkRgjP9bgMM/ag+n91rsv0U1Gpz0H3VILA/o3bW7Ua6BQ==", + "dev": true + }, + "@apidevtools/swagger-methods": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@apidevtools/swagger-methods/-/swagger-methods-3.0.2.tgz", + "integrity": "sha512-QAkD5kK2b1WfjDS/UQn/qQkbwF31uqRjPTrsCs5ZG9BQGAkjwvqGFjjPqAuzac/IYzpPtRzjCP1WrTuAIjMrXg==", + "dev": true + }, + "@apidevtools/swagger-parser": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/@apidevtools/swagger-parser/-/swagger-parser-10.0.3.tgz", + "integrity": "sha512-sNiLY51vZOmSPFZA5TF35KZ2HbgYklQnTSDnkghamzLb3EkNtcQnrBQEj5AOCxHpTtXpqMCRM1CrmV2rG6nw4g==", + "dev": true, + "requires": { + "@apidevtools/json-schema-ref-parser": "^9.0.6", + "@apidevtools/openapi-schemas": "^2.0.4", + "@apidevtools/swagger-methods": "^3.0.2", + "@jsdevtools/ono": "^7.1.3", + "call-me-maybe": "^1.0.1", + "z-schema": "^5.0.1" + } + }, + "@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", + "dev": true + }, "@types/debug": { "version": "4.1.7", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", @@ -1473,6 +1808,12 @@ "@types/ms": "*" } }, + "@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, "@types/ms": { "version": "0.7.31", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", @@ -1524,6 +1865,12 @@ "picomatch": "^2.0.4" } }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -1594,6 +1941,12 @@ "get-intrinsic": "^1.0.2" } }, + "call-me-maybe": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==", + "dev": true + }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -1632,6 +1985,12 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "commander": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.0.tgz", + "integrity": "sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q==", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1678,6 +2037,15 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, "dotenv": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", @@ -1721,6 +2089,12 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -1828,6 +2202,12 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, "fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -1854,6 +2234,20 @@ "has-symbols": "^1.0.3" } }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -1910,6 +2304,16 @@ "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz", "integrity": "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw==" }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -1951,6 +2355,15 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } + }, "jsonwebtoken": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz", @@ -2001,6 +2414,24 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", + "dev": true + }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", + "dev": true + }, + "lodash.mergewith": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz", + "integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==", + "dev": true + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -2136,6 +2567,22 @@ "ee-first": "1.1.1" } }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "openapi-types": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.0.tgz", + "integrity": "sha512-XpeCy01X6L5EpP+6Hc3jWN7rMZJ+/k1lwki/kTmWzbVhdPie3jd5O2ZtedEx8Yp58icJ0osVldLMrTB/zslQXA==", + "dev": true, + "peer": true + }, "oracledb": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/oracledb/-/oracledb-5.5.0.tgz", @@ -2146,6 +2593,12 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, + "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==", + "dev": true + }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", @@ -2398,6 +2851,44 @@ "has-flag": "^3.0.0" } }, + "swagger-jsdoc": { + "version": "6.2.8", + "resolved": "https://registry.npmjs.org/swagger-jsdoc/-/swagger-jsdoc-6.2.8.tgz", + "integrity": "sha512-VPvil1+JRpmJ55CgAtn8DIcpBs0bL5L3q5bVQvF4tAW/k/9JYSj7dCpaYCAv5rufe0vcCbBRQXGvzpkWjvLklQ==", + "dev": true, + "requires": { + "commander": "6.2.0", + "doctrine": "3.0.0", + "glob": "7.1.6", + "lodash.mergewith": "^4.6.2", + "swagger-parser": "^10.0.3", + "yaml": "2.0.0-1" + } + }, + "swagger-parser": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/swagger-parser/-/swagger-parser-10.0.3.tgz", + "integrity": "sha512-nF7oMeL4KypldrQhac8RyHerJeGPD1p2xDh900GPvc+Nk7nWP6jX2FcC7WmkinMoAmoO774+AFXcWsW8gMWEIg==", + "dev": true, + "requires": { + "@apidevtools/swagger-parser": "10.0.3" + } + }, + "swagger-ui-dist": { + "version": "4.18.3", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-4.18.3.tgz", + "integrity": "sha512-QW280Uvt234+TLo9NMPRa2Sj17RoorbQlR2eEY4R6Cs0LbdXhiO14YWX9OPBkBdiN64GQYz4zU8wlHLVi81lBg==", + "dev": true + }, + "swagger-ui-express": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-4.6.3.tgz", + "integrity": "sha512-CDje4PndhTD2HkgyKH3pab+LKspDeB/NhPN2OF1j+piYIamQqBYwAXWESOT1Yju2xFg51bRW9sUng2WxDjzArw==", + "dev": true, + "requires": { + "swagger-ui-dist": ">=4.11.0" + } + }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -2481,6 +2972,12 @@ "strip-ansi": "^6.0.0" } }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -2491,6 +2988,12 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, + "yaml": { + "version": "2.0.0-1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-1.tgz", + "integrity": "sha512-W7h5dEhywMKenDJh2iX/LABkbFnBxasD27oyXWDS/feDsxiw0dD5ncXdYXgkvAsXIY2MpW/ZKkr9IU30DBdMNQ==", + "dev": true + }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -2509,6 +3012,27 @@ "version": "20.2.9", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==" + }, + "z-schema": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-5.0.5.tgz", + "integrity": "sha512-D7eujBWkLa3p2sIpJA0d1pr7es+a7m0vFAnZLlCEKq/Ij2k0MLi9Br2UPxoxdYystm5K1yeBGzub0FlYUEWj2Q==", + "dev": true, + "requires": { + "commander": "^9.4.1", + "lodash.get": "^4.4.2", + "lodash.isequal": "^4.5.0", + "validator": "^13.7.0" + }, + "dependencies": { + "commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "dev": true, + "optional": true + } + } } } } diff --git a/server/package.json b/server/package.json index 1f3c84637..0aa5c8feb 100644 --- a/server/package.json +++ b/server/package.json @@ -22,5 +22,9 @@ "oracledb": "^5.5.0", "sequelize": "^6.31.0", "sequelize-auto": "^0.8.8" + }, + "devDependencies": { + "swagger-jsdoc": "^6.2.8", + "swagger-ui-express": "^4.6.3" } } diff --git a/server/src/routes/home/index.js b/server/src/routes/home/index.js index 4ebcb0cac..80e5085c8 100644 --- a/server/src/routes/home/index.js +++ b/server/src/routes/home/index.js @@ -6,6 +6,12 @@ router.get("/", (req, res) => { res.send("hello!"); }) +/** + * @swagger + * tags: + * name: Users + * description: 유저 관리 API + */ const user = require("../user/userRouter"); router.use("/user", user); diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index 98b583c85..4a12da41c 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -4,7 +4,79 @@ const userCrtl = require('../../controller/user/user.ctrl'); const { verifyRefreshToken } = require("../../config/jwt"); const router = require("express").Router(); +/** + * @swagger + * /user/login: + * post: + * summary: "로그인" + * description: "사용자의 email과 password을 입력받아, access token과 refresh token을 발급합니다." + * tags: [Users] + * requestBody: + * description: 유저 정보 + * required: true + * content: + * application/x-www-form-urlencoded: + * schema: + * type: object + * properties: + * email: + * type: string + * description: "유저 이메일" + * password: + * type: string + * description: "유저 비밀번호" + * responses: + * "200": + * description: 로그인 성공 + * content: + * application/json: + * schema: + * type: object + * properties: + * message: + * type: string + * example: "login success" + * accessToken: + * type: string + * example: "Access token value" + * refreshToken: + * type: string + * example: "Refresh token value" + * "401": + * description: 비밀번호 입력 오류 + * content: + * application/json: + * schema: + * type: object + * properties: + * message: + * type: string + * example: "password mismatch" + * accessToken: + * type: string + * example: null + * refreshToken: + * type: string + * example: null + * "404": + * description: 해당 유저가 존재하지 않음 + * content: + * application/json: + * schema: + * type: object + * properties: + * message: + * type: string + * example: "user not found" + * accessToken: + * type: string + * example: null + * refreshToken: + * type: string + * example: null + */ router.post("/login", userCrtl.process.login); // sign-in + router.post("/reissue", verifyRefreshToken, userCrtl.process.reissue); // reissuing token router.post("/register", userCrtl.process.register); // sign-up diff --git a/server/swagger/swagger.js b/server/swagger/swagger.js new file mode 100644 index 000000000..c67a98c5a --- /dev/null +++ b/server/swagger/swagger.js @@ -0,0 +1,23 @@ +const swaggerUi = require("swagger-ui-express") +const swaggereJsdoc = require("swagger-jsdoc") + +const options = { + swaggerDefinition: { + openapi: "3.0.0", + info: { + version: "1.0.0", + title: "MediLenz", + description: + "MediLenz API 명세서입니다.", + }, + servers: [ + { + url: "http://localhost:" + process.env.PORT, // 요청 URL + }, + ], + }, + apis: ["./src/routes/home/*.js", "./src/routes/user/*.js"], // Swagger 파일 연동 +} +const specs = swaggereJsdoc(options) + +module.exports = { swaggerUi, specs } \ No newline at end of file From 59a2fc4f32da59ee448c480508d966035869d24f Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 23 May 2023 21:58:39 +0900 Subject: [PATCH 27/70] =?UTF-8?q?#78=20=EB=B0=98=ED=99=98=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 0da7b2c0f..6b4b7c362 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -2,21 +2,21 @@ module.exports = { // Success - SIGNIN_SUCCESS: { message: "login success" }, - SIGNUP_SUCCESS: { message: "new user created" }, - REISSUE_SUCCESS: { message: "reissued tokens" }, + SIGNIN_SUCCESS: "login success", + SIGNUP_SUCCESS: "new user created", + REISSUE_SUCCESS: "reissued tokens", // Request error - JWT_INVALID_FORMAT: { message: "token is empty or sent format is wrong" }, - SIGNIN_BAD_REQUEST: { message: "paramter must include 'email(string), password(string)'" }, - SIGNIN_USER_NOT_FOUND: { message: "user not found" }, - SIGNIN_PASSWORD_MISMATCH: { message: "password mismatch" }, - SIGNUP_BAD_REQUEST: { message: "paramter must include 'email(string), password(string), nickname(string)'" }, + JWT_INVALID_FORMAT: "token is empty or sent format is wrong", + SIGNIN_BAD_REQUEST: "paramter must include 'email(string), password(string)'", + SIGNIN_USER_NOT_FOUND: "user not found", + SIGNIN_PASSWORD_MISMATCH: "password mismatch", + SIGNUP_BAD_REQUEST: "paramter must include 'email(string), password(string), nickname(string)'", // Response error SIGNUP_DUPLICATE_PARAMETER: (parameter) => { - return { message: `the ${parameter} is already in use` } + return `the ${parameter} is already in use` }, - SIGNUP_INTERNAL_SERVER_ERROR: { message: "DB Error" } + SIGNUP_INTERNAL_SERVER_ERROR: "DB Error" } \ No newline at end of file From 6c12ae63c709047f43df1c6eedfa42d6e95817c2 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 23 May 2023 22:00:38 +0900 Subject: [PATCH 28/70] =?UTF-8?q?#78=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8=20=EC=8B=9C=EC=9D=98=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=8F=AC=EB=A7=B7=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/userService.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 59fcea5c7..a58c1b909 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -5,6 +5,15 @@ const { responseFormat } = require("../config/response"); const responseMsg = require("../config/responseMsg"); const { createAccessToken, createRefreshToken } = require("../config/jwt"); +// sign-in response format +const loginResponseFormat = (message, access_token = null, refresh_token = null) => { + return { + message, + access_token, + refresh_token + } +} + // sign-in const login = async (email, password) => { const userInfo = await User.findOne({ @@ -14,16 +23,16 @@ const login = async (email, password) => { } }); if (!userInfo) { // if user not exists - return responseFormat(404, responseMsg.SIGNIN_USER_NOT_FOUND); + return responseFormat(404, loginResponseFormat(responseMsg.SIGNIN_USER_NOT_FOUND)); } if (password != userInfo.PASSWORD) { // password mismatch - return responseFormat(401, responseMsg.SIGNIN_PASSWORD_MISMATCH); + return responseFormat(401, loginResponseFormat(responseMsg.SIGNIN_PASSWORD_MISMATCH)); } - const response = responseMsg.SIGNIN_SUCCESS; - response.accessToken = createAccessToken(userInfo.USERID); // generate access token - response.refreshToken = createRefreshToken(userInfo.USERID); // generate refresh token + const message = responseMsg.SIGNIN_SUCCESS; // generate response message + const accessToken = createAccessToken(userInfo.USERID); // generate access token + const refreshToken = createRefreshToken(userInfo.USERID); // generate refresh token - return responseFormat(200, response); + return responseFormat(200, loginResponseFormat(message, accessToken, refreshToken)); } // duplicate check From 574e4e8483a919b24e360fb19018a0e39cf0cd3e Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 24 May 2023 03:49:55 +0900 Subject: [PATCH 29/70] =?UTF-8?q?#80=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=8B=A4=ED=8C=A8=20=EC=8B=9C=EC=9D=98=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=8F=AC=EB=A7=B7=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/userService.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/server/src/service/userService.js b/server/src/service/userService.js index a58c1b909..3a0eb5043 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -6,7 +6,7 @@ const responseMsg = require("../config/responseMsg"); const { createAccessToken, createRefreshToken } = require("../config/jwt"); // sign-in response format -const loginResponseFormat = (message, access_token = null, refresh_token = null) => { +const tokenResponseFormat = (message, access_token = null, refresh_token = null) => { return { message, access_token, @@ -23,16 +23,16 @@ const login = async (email, password) => { } }); if (!userInfo) { // if user not exists - return responseFormat(404, loginResponseFormat(responseMsg.SIGNIN_USER_NOT_FOUND)); + return responseFormat(404, tokenResponseFormat(responseMsg.SIGNIN_USER_NOT_FOUND)); } if (password != userInfo.PASSWORD) { // password mismatch - return responseFormat(401, loginResponseFormat(responseMsg.SIGNIN_PASSWORD_MISMATCH)); + return responseFormat(401, tokenResponseFormat(responseMsg.SIGNIN_PASSWORD_MISMATCH)); } const message = responseMsg.SIGNIN_SUCCESS; // generate response message const accessToken = createAccessToken(userInfo.USERID); // generate access token const refreshToken = createRefreshToken(userInfo.USERID); // generate refresh token - return responseFormat(200, loginResponseFormat(message, accessToken, refreshToken)); + return responseFormat(200, tokenResponseFormat(message, accessToken, refreshToken)); } // duplicate check @@ -50,11 +50,11 @@ const createUser = async (email, password, nickname) => { // duplicate check let checkParam = "EMAIL" if (await duplicateCheck({ [checkParam]: email })) { // email - return responseFormat(409, responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam)); + return responseFormat(409, tokenResponseFormat(responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam))); } checkParam = "NICKNAME"; if (await duplicateCheck({ [checkParam]: nickname })) { // nickname - return responseFormat(409, responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam)); + return responseFormat(409, tokenResponseFormat(responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam))); } try { @@ -63,15 +63,17 @@ const createUser = async (email, password, nickname) => { PASSWORD: password, NICKNAME: nickname }); - const response = responseMsg.SIGNUP_SUCCESS; - response.accessToken = createAccessToken(user.USERID); // generate access token - response.refreshToken = createRefreshToken(user.USERID); // generate refresh token - return responseFormat(201, response); + const message = responseMsg.SIGNUP_SUCCESS; // generate response message + const accessToken = createAccessToken(user.ID); // generate access token + const refreshToken = createRefreshToken(user.ID); // generate refresh token + + return responseFormat(201, tokenResponseFormat(message, accessToken, refreshToken)); + } catch (err) { console.log(err); - return responseFormat(500, responseMsg.SIGNUP_INTERNAL_SERVER_ERROR); + return responseFormat(500, tokenResponseFormat(responseMsg.SIGNUP_INTERNAL_SERVER_ERROR)); } } From 273170d25ded026c33893d3bc5d95cdebdadf0ed Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 24 May 2023 04:06:29 +0900 Subject: [PATCH 30/70] =?UTF-8?q?#80=20Swagger=20API=20=EB=AA=85=EC=84=B8?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 2 +- server/src/routes/user/userRouter.js | 75 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 6b4b7c362..3d3da4b86 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -17,6 +17,6 @@ module.exports = { SIGNUP_DUPLICATE_PARAMETER: (parameter) => { return `the ${parameter} is already in use` }, - SIGNUP_INTERNAL_SERVER_ERROR: "DB Error" + SIGNUP_INTERNAL_SERVER_ERROR: "server error" } \ No newline at end of file diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index 4a12da41c..bf38c77aa 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -78,6 +78,81 @@ const router = require("express").Router(); router.post("/login", userCrtl.process.login); // sign-in router.post("/reissue", verifyRefreshToken, userCrtl.process.reissue); // reissuing token + +/** + * @swagger + * /user/register: + * post: + * summary: "회원가입" + * description: "사용자로부터 email, nickname, password를 입력받아 DB에 저장하고, access token과 refresh token을 발급합니다." + * tags: [Users] + * requestBody: + * description: 유저 정보 + * required: true + * content: + * application/x-www-form-urlencoded: + * schema: + * type: object + * properties: + * email: + * type: string + * description: "유저 이메일" + * password: + * type: string + * description: "유저 비밀번호" + * nickname: + * type: string + * description: "유저 닉네임" + * responses: + * "201": + * description: 회원가입 성공 + * content: + * application/json: + * schema: + * type: object + * properties: + * message: + * type: string + * example: "new user created" + * accessToken: + * type: string + * example: "Access token value" + * refreshToken: + * type: string + * example: "Refresh token value" + * "409": + * description: 이메일 or 닉네임 중복 + * content: + * application/json: + * schema: + * type: object + * properties: + * message: + * type: string + * example: "the email is already in use" + * accessToken: + * type: string + * example: null + * refreshToken: + * type: string + * example: null + * "500": + * description: 서버 오류 + * content: + * application/json: + * schema: + * type: object + * properties: + * message: + * type: string + * example: "server error" + * accessToken: + * type: string + * example: null + * refreshToken: + * type: string + * example: null + */ router.post("/register", userCrtl.process.register); // sign-up module.exports = router; \ No newline at end of file From 126371c170c4b8a6ac0d74fd38160d22f7da5b7b Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 24 May 2023 23:36:00 +0900 Subject: [PATCH 31/70] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8C=85=20api=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/routes/home/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/routes/home/index.js b/server/src/routes/home/index.js index 80e5085c8..a65fbb05b 100644 --- a/server/src/routes/home/index.js +++ b/server/src/routes/home/index.js @@ -2,8 +2,8 @@ const router = require("express").Router(); -router.get("/", (req, res) => { - res.send("hello!"); +router.post("/", (req, res) => { + res.send(req.body); }) /** From 2a7424c102d4b7afc06fe0d7644a022e90c0070b Mon Sep 17 00:00:00 2001 From: winocreative Date: Tue, 30 May 2023 17:49:20 +0900 Subject: [PATCH 32/70] =?UTF-8?q?#75=20:=20getMedicineId=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80=20->=20=EC=95=BD=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EA=B8=B0=EB=B0=98=EC=9C=BC=EB=A1=9C=20DB?= =?UTF-8?q?=EC=97=90=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20=ED=95=B4=EB=8B=B9=20?= =?UTF-8?q?ID=20=EC=B6=9C=EB=A0=A5,=20=EC=97=86=EC=9C=BC=EB=A9=B4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=ED=9B=84=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/commentService.js | 5 ++++ server/src/service/medicineService.js | 36 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 server/src/service/commentService.js create mode 100644 server/src/service/medicineService.js diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js new file mode 100644 index 000000000..780b7a366 --- /dev/null +++ b/server/src/service/commentService.js @@ -0,0 +1,5 @@ +// "use strict"; + +// const { Comment } = require("../models/index"); + +// const writeComment = async (userId, medicineId, comment, ) => { \ No newline at end of file diff --git a/server/src/service/medicineService.js b/server/src/service/medicineService.js new file mode 100644 index 000000000..7712280e0 --- /dev/null +++ b/server/src/service/medicineService.js @@ -0,0 +1,36 @@ +"use strict"; + +const { Medicine } = require("../models/index"); + +const getMedicineId = async (item_seq, item_name, item_ingr_name, prduct_type, entp_name, spclty_pblc, ingredient_name) => { + const medicine = await Medicine.findOne({ + attributes: ["ID"], + where: { + ITEM_SEQ: item_seq, + ITEM_NAME: item_name, + ITEM_INGR_NAME: item_ingr_name, + PRDUCT_TYPE: prduct_type, + ENTP_NAME: entp_name, + SPCLTY_PBLC: spclty_pblc, + INGREDIENT_NAME: ingredient_name + } + }); + if (!medicine) { + //Add medicine data to db + const newMedicine = await Medicine.create({ + ITEM_SEQ: item_seq, + ITEM_NAME: item_name, + ITEM_INGR_NAME: item_ingr_name, + PRDUCT_TYPE: prduct_type, + ENTP_NAME: entp_name, + SPCLTY_PBLC: spclty_pblc, + INGREDIENT_NAME: ingredient_name + }); + return newMedicine.ID; + } + return medicine.ID; +} + +module.exports = { + getMedicineId +} \ No newline at end of file From 71e10ef7373db9e8a23ef2067723edfd60384775 Mon Sep 17 00:00:00 2001 From: winocreative Date: Tue, 30 May 2023 18:04:09 +0900 Subject: [PATCH 33/70] =?UTF-8?q?#75=20:=20writeComment=EC=99=80=20deleteC?= =?UTF-8?q?omment=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/commentService.js | 43 +++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index 780b7a366..61096cc86 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -1,5 +1,40 @@ -// "use strict"; +"use strict"; -// const { Comment } = require("../models/index"); - -// const writeComment = async (userId, medicineId, comment, ) => { \ No newline at end of file +const { Comment } = require("../models/index"); +const writeComment = async (userId, medicineId, comment, subOrdinationId) => { + const newComment = await Comment.create({ + USERID: userId, + MEDICINEID: medicineId, + COMMENT: comment, + SUBORDINATIONID: subOrdinationId + }); + return newComment.ID; +} +const deleteComment = async (commentId) => { + const comment = await Comment.findOne({ + where: { + ID: commentId + } + }); + if (!comment) { + return false; + } + if (comment.SUBORDINATIONID == 0) { + //delete comment with no subordination + await Comment.destroy({ + where: { + ID: commentId + } + }); + return true; + } + //replace content with "삭제된 댓글입니다." + await Comment.update({ + COMMENT: "삭제된 댓글입니다." + }, { + where: { + ID: commentId + } + }); + return true; +} \ No newline at end of file From d9c04d399b118b17de9e61a0e9788cbfcec2d5da Mon Sep 17 00:00:00 2001 From: winocreative Date: Tue, 30 May 2023 18:06:44 +0900 Subject: [PATCH 34/70] =?UTF-8?q?#75=20:=20editComment=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/commentService.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index 61096cc86..acafe30f1 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -37,4 +37,22 @@ const deleteComment = async (commentId) => { } }); return true; +} +const editComment = async (commentId, comment) => { + const targetComment = await Comment.findOne({ + where: { + ID: commentId + } + }); + if (!targetComment) { + return false; + } + await Comment.update({ + COMMENT: comment + }, { + where: { + ID: commentId + } + }); + return true; } \ No newline at end of file From af3aa29f58883ad6dd2323fc987000cdde7b2726 Mon Sep 17 00:00:00 2001 From: winocreative Date: Tue, 30 May 2023 20:26:39 +0900 Subject: [PATCH 35/70] =?UTF-8?q?#75=20:=20getCommentList=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/commentService.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index acafe30f1..97a646cd9 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -20,7 +20,6 @@ const deleteComment = async (commentId) => { return false; } if (comment.SUBORDINATIONID == 0) { - //delete comment with no subordination await Comment.destroy({ where: { ID: commentId @@ -28,7 +27,6 @@ const deleteComment = async (commentId) => { }); return true; } - //replace content with "삭제된 댓글입니다." await Comment.update({ COMMENT: "삭제된 댓글입니다." }, { @@ -55,4 +53,29 @@ const editComment = async (commentId, comment) => { } }); return true; +} +const getCommentList = async (medicineId) => { + const commentList = await Comment.findAll({ + where: { + MEDICINEID: medicineId + } + }); + + alignedCommentList = [] + for (let comment in commentList) { + if (comment.SUBORDINATION == 0) continue; + comment.replies = []; + alignedCommentList.push(comment); + } + + for (let i = 0; i < commentList.length; i++) { + if (commentList[i].SUBORDINATION != 0) { + for (let j = 0; j < alignedCommentList.length; j++) { + if (commentList[i].SUBORDINATION == alignedCommentList[j].ID) { + alignedCommentList[j].replies.push(commentList[i]); + } + } + } + } + return commentList; } \ No newline at end of file From 44ad85e913f53c6366302d1c2658385bd96948ee Mon Sep 17 00:00:00 2001 From: winocreative Date: Fri, 2 Jun 2023 20:33:13 +0900 Subject: [PATCH 36/70] =?UTF-8?q?#75=20=EB=8C=93=EA=B8=80=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80,=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EB=B6=88=EB=9F=AC?= =?UTF-8?q?=EC=98=A4=EA=B8=B0=20=EB=9D=BC=EC=9A=B0=ED=8C=85,=20=EC=A2=8B?= =?UTF-8?q?=EC=95=84=EC=9A=94=20=ED=95=A8=EC=88=98=20=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/www.js | 2 +- server/src/config/responseMsg.js | 7 +- server/src/controller/comment/index.js | 25 ++++++ server/src/models/medicine.js | 5 -- server/src/routes/home/index.js | 2 + server/src/routes/medicine/comment/index.js | 8 ++ server/src/routes/medicine/index.js | 7 ++ server/src/service/commentService.js | 98 ++++++++++++++++----- server/src/service/medicineService.js | 15 ++-- 9 files changed, 131 insertions(+), 38 deletions(-) create mode 100644 server/src/controller/comment/index.js create mode 100644 server/src/routes/medicine/comment/index.js create mode 100644 server/src/routes/medicine/index.js diff --git a/server/bin/www.js b/server/bin/www.js index 8d0dd83a3..5c1ee6e28 100644 --- a/server/bin/www.js +++ b/server/bin/www.js @@ -15,7 +15,7 @@ app.listen(PORT, async () => { } try { - await models.sequelize.sync(); + await models.sequelize.sync({force: false, alter: false}); } catch (err) { console.log('DB 연결 중 오류 발생: ', err); process.exit(); diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 6b4b7c362..61742455b 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -17,6 +17,11 @@ module.exports = { SIGNUP_DUPLICATE_PARAMETER: (parameter) => { return `the ${parameter} is already in use` }, - SIGNUP_INTERNAL_SERVER_ERROR: "DB Error" + SIGNUP_INTERNAL_SERVER_ERROR: "DB Error", + // Comment + COMMENT_WRITE_COMPLETE: "comment write complete", + + // Medicine + MEDICINE_ID_FOUND: "medicine id found", } \ No newline at end of file diff --git a/server/src/controller/comment/index.js b/server/src/controller/comment/index.js new file mode 100644 index 000000000..f35373a6c --- /dev/null +++ b/server/src/controller/comment/index.js @@ -0,0 +1,25 @@ +"use strict"; + +const {getMedicineId} = require("../../service/medicineService"); +const {writeComment, deleteComment, editComment, getCommentList} = require("../../service/commentService"); + +const get = async (req, res) => { + //item_seq, item_name, item_ingr_name, prduct_type, entp_name, spclty_pblc as POST + const {ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC} = req.body; + const result = await getMedicineId(ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC); + if (result.code != 200) { return res.status(result.code).send(result.response); } + const medicineId = result.response.medicineId; + const commentList = await getCommentList(medicineId); + return res.status(200).send(commentList); +} +const writeTest = async (req, res) => { + //userId, medicineId, comment, subOrdinationId as POST + const {userId, medicineId, content, subOrdinationId} = req.body; + console.log(userId, medicineId, content, subOrdinationId); + const result = await writeComment(userId, medicineId, content, subOrdinationId); + return res.status(result.code).send(result.response); +} +module.exports = { + get, + writeTest +} \ No newline at end of file diff --git a/server/src/models/medicine.js b/server/src/models/medicine.js index e90fc4ee4..7185bdbfb 100644 --- a/server/src/models/medicine.js +++ b/server/src/models/medicine.js @@ -38,11 +38,6 @@ module.exports = function (sequelize, DataTypes) { field: 'SPCLTY_PBLC', type: DataTypes.STRING, allowNull: false - }, - INGREDIENT_NAME: { - field: 'INGREDIENT_NAME', - type: DataTypes.STRING, - allowNull: false } }, { underscored: true, diff --git a/server/src/routes/home/index.js b/server/src/routes/home/index.js index 80e5085c8..2ce8c65f2 100644 --- a/server/src/routes/home/index.js +++ b/server/src/routes/home/index.js @@ -15,4 +15,6 @@ router.get("/", (req, res) => { const user = require("../user/userRouter"); router.use("/user", user); +const medicine = require("../medicine"); +router.use("/medicine", medicine); module.exports = router; \ No newline at end of file diff --git a/server/src/routes/medicine/comment/index.js b/server/src/routes/medicine/comment/index.js new file mode 100644 index 000000000..a855d84f3 --- /dev/null +++ b/server/src/routes/medicine/comment/index.js @@ -0,0 +1,8 @@ +"use strict"; + +const router = require("express").Router(); +const commentController = require("../../../controller/comment"); + +router.post("/", commentController.get); +router.post("/writeTest", commentController.writeTest); +module.exports = router; \ No newline at end of file diff --git a/server/src/routes/medicine/index.js b/server/src/routes/medicine/index.js new file mode 100644 index 000000000..af76aed1d --- /dev/null +++ b/server/src/routes/medicine/index.js @@ -0,0 +1,7 @@ +"use strict"; + +const router = require("express").Router(); +const commentRouter = require('./comment'); + +router.use("/comment", commentRouter); +module.exports = router; \ No newline at end of file diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index 97a646cd9..49b78979a 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -1,14 +1,57 @@ "use strict"; -const { Comment } = require("../models/index"); -const writeComment = async (userId, medicineId, comment, subOrdinationId) => { +const { Comment, Like } = require("../models/index"); +const { responseFormat } = require("../config/response"); +const responseMsg = require("../config/responseMsg"); + +const addLike = async (userId, commentId) => { + try { + const newLike = await Like.create({ + USERID: userId, + COMMENTID: commentId + }); + return responseFormat(200, { message: responseMsg.LIKE_ADD_COMPLETE, likeId: newLike.ID }); + } catch (err) { + return responseFormat(500, { message: responseMsg.LIKE_ADD_FAIL }); + } +} +const removeLike = async (userId, commentId) => { + try { + await Like.destroy({ + where: { + USERID: userId, + COMMENTID: commentId + } + }); + return responseFormat(200, { message: responseMsg.LIKE_REMOVE_COMPLETE }); + } catch (err) { + return responseFormat(500, { message: responseMsg.LIKE_REMOVE_FAIL }); + } +} +const getLikeList = async (commentId) => { + try { + const likeList = await Like.findAll({ + where: { + COMMENTID: commentId + } + }); + _likeList = []; + for (let i in likeList) { + _likeList.push(likeList[i].dataValues); + } + return _likeList; + } catch (err) { + return []; + } +} +const writeComment = async (userId, medicineId, content, subOrdinationId) => { const newComment = await Comment.create({ USERID: userId, MEDICINEID: medicineId, - COMMENT: comment, - SUBORDINATIONID: subOrdinationId + CONTENT: content, + SUBORDINATION: subOrdinationId }); - return newComment.ID; + return responseFormat(200, { message: responseMsg.COMMENT_WRITE_COMPLETE, commentId: newComment.ID }); } const deleteComment = async (commentId) => { const comment = await Comment.findOne({ @@ -28,7 +71,7 @@ const deleteComment = async (commentId) => { return true; } await Comment.update({ - COMMENT: "삭제된 댓글입니다." + CONTENT: "삭제된 댓글입니다." }, { where: { ID: commentId @@ -36,7 +79,7 @@ const deleteComment = async (commentId) => { }); return true; } -const editComment = async (commentId, comment) => { +const editComment = async (commentId, content) => { const targetComment = await Comment.findOne({ where: { ID: commentId @@ -46,7 +89,7 @@ const editComment = async (commentId, comment) => { return false; } await Comment.update({ - COMMENT: comment + CONTENT: content }, { where: { ID: commentId @@ -60,22 +103,31 @@ const getCommentList = async (medicineId) => { MEDICINEID: medicineId } }); - - alignedCommentList = [] - for (let comment in commentList) { - if (comment.SUBORDINATION == 0) continue; - comment.replies = []; - alignedCommentList.push(comment); + let _commentList = []; + for (let i in commentList) { + let _comment = commentList[i].dataValues; + if (_comment.SUBORDINATION != 0) continue; + _comment.likeList = await getLikeList(_comment.ID); + _comment.replies = []; + _commentList.push(_comment); } - - for (let i = 0; i < commentList.length; i++) { - if (commentList[i].SUBORDINATION != 0) { - for (let j = 0; j < alignedCommentList.length; j++) { - if (commentList[i].SUBORDINATION == alignedCommentList[j].ID) { - alignedCommentList[j].replies.push(commentList[i]); - } + for (let i in commentList) { + let _comment = commentList[i].dataValues; + if (_comment.SUBORDINATION == 0) continue; + for (let j in _commentList) { + if (_comment.SUBORDINATION == _commentList[j].ID) { + _comment.likeList = await getLikeList(_comment.ID); + _commentList[j].replies.push(_comment); + break; } } } - return commentList; -} \ No newline at end of file + return _commentList; +} + +module.exports = { + writeComment, + deleteComment, + editComment, + getCommentList +}; \ No newline at end of file diff --git a/server/src/service/medicineService.js b/server/src/service/medicineService.js index 7712280e0..6ddff5fdf 100644 --- a/server/src/service/medicineService.js +++ b/server/src/service/medicineService.js @@ -1,18 +1,18 @@ "use strict"; const { Medicine } = require("../models/index"); +const { responseFormat } = require("../config/response"); +const responseMsg = require("../config/responseMsg"); -const getMedicineId = async (item_seq, item_name, item_ingr_name, prduct_type, entp_name, spclty_pblc, ingredient_name) => { +const getMedicineId = async (item_seq, item_name, item_ingr_name, prduct_type, entp_name, spclty_pblc) => { const medicine = await Medicine.findOne({ - attributes: ["ID"], where: { ITEM_SEQ: item_seq, ITEM_NAME: item_name, ITEM_INGR_NAME: item_ingr_name, PRDUCT_TYPE: prduct_type, ENTP_NAME: entp_name, - SPCLTY_PBLC: spclty_pblc, - INGREDIENT_NAME: ingredient_name + SPCLTY_PBLC: spclty_pblc } }); if (!medicine) { @@ -23,12 +23,11 @@ const getMedicineId = async (item_seq, item_name, item_ingr_name, prduct_type, e ITEM_INGR_NAME: item_ingr_name, PRDUCT_TYPE: prduct_type, ENTP_NAME: entp_name, - SPCLTY_PBLC: spclty_pblc, - INGREDIENT_NAME: ingredient_name + SPCLTY_PBLC: spclty_pblc }); - return newMedicine.ID; + return responseFormat(200, {message: responseMsg.MEDICINE_ID_FOUND, medicineId: newMedicine.ID}); } - return medicine.ID; + return responseFormat(200, {message: responseMsg.MEDICINE_ID_FOUND, medicineId: medicine.ID}); } module.exports = { From 23d6bcf55f9a9c90f42504568dcb82ae65d1264c Mon Sep 17 00:00:00 2001 From: winocreative Date: Fri, 2 Jun 2023 20:54:39 +0900 Subject: [PATCH 37/70] =?UTF-8?q?#75=20:=20=EC=A2=8B=EC=95=84=EC=9A=94=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EB=9D=BC=EC=9A=B0=ED=8C=85,=20=EB=AF=B8?= =?UTF-8?q?=EB=93=A4=EC=9B=A8=EC=96=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 8 ++++++ server/src/controller/comment/index.js | 28 +++++++++++++++++++-- server/src/routes/medicine/comment/index.js | 10 +++++++- server/src/service/commentService.js | 21 +++++++++++++++- 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 61742455b..d5dc3cbda 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -24,4 +24,12 @@ module.exports = { // Medicine MEDICINE_ID_FOUND: "medicine id found", + + // Like + LIKE_ADD_COMPLETE: "like add complete", + LIKE_REMOVE_COMPLETE: "like remove complete", + LIKE_ADD_FAIL: "like add fail", + LIKE_REMOVE_FAIL: "like remove fail", + LIKE_FOUND: "like found", + LIKE_NOT_FOUND: "like not found", } \ No newline at end of file diff --git a/server/src/controller/comment/index.js b/server/src/controller/comment/index.js index f35373a6c..1d3c7ebf8 100644 --- a/server/src/controller/comment/index.js +++ b/server/src/controller/comment/index.js @@ -1,8 +1,9 @@ "use strict"; const {getMedicineId} = require("../../service/medicineService"); -const {writeComment, deleteComment, editComment, getCommentList} = require("../../service/commentService"); +const {writeComment, deleteComment, editComment, getCommentList, addLike, removeLike, isLiked} = require("../../service/commentService"); +//userId is in req.verifiedToken const get = async (req, res) => { //item_seq, item_name, item_ingr_name, prduct_type, entp_name, spclty_pblc as POST const {ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC} = req.body; @@ -19,7 +20,30 @@ const writeTest = async (req, res) => { const result = await writeComment(userId, medicineId, content, subOrdinationId); return res.status(result.code).send(result.response); } + +const likeGet = async (req, res) => { + const {commentId} = req.query; + const {userId} = req.verifiedToken; + const result = await isLiked(userId, commentId); + return res.status(result.code).send(result.response); +} +const likePost = async (req, res) => { //addLike + const {commentId} = req.body; + const {userId} = req.verifiedToken; + const result = await addLike(userId, commentId); + return res.status(result.code).send(result.response); +} +const likeDelete = async (req, res) => { //removeLike + const {commentId} = req.body; + const {userId} = req.verifiedToken; + const result = await removeLike(userId, commentId); + return res.status(result.code).send(result.response); +} + module.exports = { get, - writeTest + writeTest, + likeGet, + likePost, + likeDelete } \ No newline at end of file diff --git a/server/src/routes/medicine/comment/index.js b/server/src/routes/medicine/comment/index.js index a855d84f3..3ac7ccb71 100644 --- a/server/src/routes/medicine/comment/index.js +++ b/server/src/routes/medicine/comment/index.js @@ -2,7 +2,15 @@ const router = require("express").Router(); const commentController = require("../../../controller/comment"); +//verifyAccessToken +const { verifyAccessToken } = require("../../../config/jwt"); +// Comment router.post("/", commentController.get); -router.post("/writeTest", commentController.writeTest); +router.post("/writeTest", verifyAccessToken, commentController.writeTest); + +// Like +router.get("/like", verifyAccessToken, commentController.likeGet); +router.post("/like", verifyAccessToken, commentController.likePost); +router.delete("/like", verifyAccessToken, commentController.likeDelete); module.exports = router; \ No newline at end of file diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index 49b78979a..1effe4780 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -28,6 +28,22 @@ const removeLike = async (userId, commentId) => { return responseFormat(500, { message: responseMsg.LIKE_REMOVE_FAIL }); } } +const isLiked = async (userId, commentId) => { + try { + const like = await Like.findOne({ + where: { + USERID: userId, + COMMENTID: commentId + } + }); + if (!like) { + return responseFormat(200, { message: responseMsg.LIKE_NOT_FOUND }); + } + return responseFormat(200, { message: responseMsg.LIKE_FOUND }); + } catch (err) { + return responseFormat(500, { message: responseMsg.LIKE_NOT_FOUND }); + } +} const getLikeList = async (commentId) => { try { const likeList = await Like.findAll({ @@ -126,8 +142,11 @@ const getCommentList = async (medicineId) => { } module.exports = { + addLike, + removeLike, writeComment, deleteComment, editComment, - getCommentList + getCommentList, + isLiked }; \ No newline at end of file From 7d4b07f6a744b126af720672c01bbac67cb28a30 Mon Sep 17 00:00:00 2001 From: winocreative Date: Sat, 3 Jun 2023 05:02:08 +0900 Subject: [PATCH 38/70] =?UTF-8?q?#75=20:=20=EB=8C=93=EA=B8=80=20CRUD=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=8C=85=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 8 +- server/src/controller/comment/index.js | 29 ++- server/src/routes/medicine/comment/index.js | 13 +- server/src/service/commentService.js | 216 ++++++++++++-------- 4 files changed, 167 insertions(+), 99 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index d5dc3cbda..f94c4808f 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -20,8 +20,14 @@ module.exports = { SIGNUP_INTERNAL_SERVER_ERROR: "DB Error", // Comment + COMMENT_GET_COMPLETE: "comment get complete", COMMENT_WRITE_COMPLETE: "comment write complete", - + COMMENT_WRITE_FAIL: "comment write fail", + COMMENT_NOT_FOUND: "comment not found", + COMMENT_DELETE_COMPLETE: "comment delete complete", + COMMENT_DELETE_FAIL: "comment delete fail", + COMMENT_EDIT_COMPLETE: "comment edit complete", + COMMENT_EDIT_FAIL: "comment edit fail", // Medicine MEDICINE_ID_FOUND: "medicine id found", diff --git a/server/src/controller/comment/index.js b/server/src/controller/comment/index.js index 1d3c7ebf8..552890f96 100644 --- a/server/src/controller/comment/index.js +++ b/server/src/controller/comment/index.js @@ -1,29 +1,36 @@ "use strict"; const {getMedicineId} = require("../../service/medicineService"); -const {writeComment, deleteComment, editComment, getCommentList, addLike, removeLike, isLiked} = require("../../service/commentService"); +const {writeComment, deleteComment, getCommentList, editComment, addLike, removeLike, isLiked} = require("../../service/commentService"); //userId is in req.verifiedToken const get = async (req, res) => { //item_seq, item_name, item_ingr_name, prduct_type, entp_name, spclty_pblc as POST const {ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC} = req.body; - const result = await getMedicineId(ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC); + let result = await getMedicineId(ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC); if (result.code != 200) { return res.status(result.code).send(result.response); } - const medicineId = result.response.medicineId; - const commentList = await getCommentList(medicineId); - return res.status(200).send(commentList); + result = await getCommentList(result.response); + return res.status(result.code).send(result.response); } const writeTest = async (req, res) => { - //userId, medicineId, comment, subOrdinationId as POST const {userId, medicineId, content, subOrdinationId} = req.body; - console.log(userId, medicineId, content, subOrdinationId); const result = await writeComment(userId, medicineId, content, subOrdinationId); return res.status(result.code).send(result.response); } - -const likeGet = async (req, res) => { - const {commentId} = req.query; +const patch = async (req, res) => { + const {medicineId, commentId, content} = req.body; const {userId} = req.verifiedToken; + const result = await editComment(userId, medicineId, commentId, content); + return res.status(result.code).send(result.response); +} +const del = async (req, res) => { + const {medicineId, commentId} = req.body; + const {userId} = req.verifiedToken; + const result = await deleteComment(userId, medicineId, commentId); + return res.status(result.code).send(result.response); +} +const likeGet = async (req, res) => { + const {commentId, userId} = req.query; const result = await isLiked(userId, commentId); return res.status(result.code).send(result.response); } @@ -43,6 +50,8 @@ const likeDelete = async (req, res) => { //removeLike module.exports = { get, writeTest, + patch, + del, likeGet, likePost, likeDelete diff --git a/server/src/routes/medicine/comment/index.js b/server/src/routes/medicine/comment/index.js index 3ac7ccb71..2caa72d60 100644 --- a/server/src/routes/medicine/comment/index.js +++ b/server/src/routes/medicine/comment/index.js @@ -2,15 +2,16 @@ const router = require("express").Router(); const commentController = require("../../../controller/comment"); -//verifyAccessToken const { verifyAccessToken } = require("../../../config/jwt"); // Comment -router.post("/", commentController.get); -router.post("/writeTest", verifyAccessToken, commentController.writeTest); +router.post("/writeTest", verifyAccessToken, commentController.writeTest); //CREATE +router.post("/", commentController.get); //READ +router.patch("/", verifyAccessToken, commentController.patch); //UPDATE +router.delete("/", verifyAccessToken, commentController.del); //DELETE // Like -router.get("/like", verifyAccessToken, commentController.likeGet); -router.post("/like", verifyAccessToken, commentController.likePost); -router.delete("/like", verifyAccessToken, commentController.likeDelete); +router.get("/like", commentController.likeGet); //READ +router.post("/like", verifyAccessToken, commentController.likePost); //CREATE +router.delete("/like", verifyAccessToken, commentController.likeDelete); //DELETE module.exports = router; \ No newline at end of file diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index 1effe4780..42a7def4d 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -4,6 +4,67 @@ const { Comment, Like } = require("../models/index"); const { responseFormat } = require("../config/response"); const responseMsg = require("../config/responseMsg"); +const _getLikeList = async (commentId) => { //NOT FOR EXPORT + try { + const likeList = await Like.findAll({ + where: { + COMMENTID: commentId + } + }); + _likeList = []; + for (let i in likeList) { + _likeList.push(likeList[i].dataValues); + } + return _likeList; + } catch (err) { + return []; + } +} +const _getCommentList = async (medicineId) => { //NOT FOR EXPORT + const commentList = await Comment.findAll({ + where: { + MEDICINEID: medicineId + } + }); + let _commentList = []; + for (let i in commentList) { + let _comment = commentList[i].dataValues; + if (_comment.SUBORDINATION != 0) continue; + _comment.likeList = await _getLikeList(_comment.ID); + _comment.replies = []; + _commentList.push(_comment); + } + for (let i in commentList) { + let _comment = commentList[i].dataValues; + if (_comment.SUBORDINATION == 0) continue; + for (let j in _commentList) { + if (_comment.SUBORDINATION == _commentList[j].ID) { + _comment.likeList = await _getLikeList(_comment.ID); + _commentList[j].replies.push(_comment); + break; + } + } + } + return _commentList; +} +const _getReplyList = async (medicineId, commentId) => { //NOT FOR EXPORT + const commentList = await Comment.findAll({ + where: { + MEDICINEID: medicineId, + SUBORDINATION: commentId + } + }); + let _commentList = []; + for (let i in commentList) { + let _comment = commentList[i].dataValues; + _commentList.push(_comment); + } + return _commentList; +} +const getCommentList = async (medicineId) => { + const commentList = await _getCommentList(medicineId); + return responseFormat(200, { message: responseMsg.COMMENT_GET_COMPLETE, commentList: commentList }); +} const addLike = async (userId, commentId) => { try { const newLike = await Like.create({ @@ -44,109 +105,100 @@ const isLiked = async (userId, commentId) => { return responseFormat(500, { message: responseMsg.LIKE_NOT_FOUND }); } } -const getLikeList = async (commentId) => { +const writeComment = async (userId, medicineId, content, subOrdinationId) => { try { - const likeList = await Like.findAll({ - where: { - COMMENTID: commentId - } + const newComment = await Comment.create({ + USERID: userId, + MEDICINEID: medicineId, + CONTENT: content, + SUBORDINATION: subOrdinationId }); - _likeList = []; - for (let i in likeList) { - _likeList.push(likeList[i].dataValues); - } - return _likeList; + return responseFormat(200, { message: responseMsg.COMMENT_WRITE_COMPLETE, commentId: newComment.ID }); } catch (err) { - return []; + return responseFormat(500, { message: responseMsg.COMMENT_WRITE_FAIL }); } } -const writeComment = async (userId, medicineId, content, subOrdinationId) => { - const newComment = await Comment.create({ - USERID: userId, - MEDICINEID: medicineId, - CONTENT: content, - SUBORDINATION: subOrdinationId - }); - return responseFormat(200, { message: responseMsg.COMMENT_WRITE_COMPLETE, commentId: newComment.ID }); -} -const deleteComment = async (commentId) => { - const comment = await Comment.findOne({ - where: { - ID: commentId +const deleteComment = async (medicineId, commentId) => { + try { + const transaction = await sequelize.transaction(); + const comment = await Comment.findOne({ + where: { + ID: commentId, + MEDICINEID: medicineId + } + }, { transaction }); + if (!comment) { + await transaction.rollback(); + return responseFormat(404, { message: responseMsg.COMMENT_NOT_FOUND }); } - }); - if (!comment) { - return false; - } - if (comment.SUBORDINATIONID == 0) { - await Comment.destroy({ + if (_getReplyList(commentId, medicineId).length == 0) { //댓글에 달린 답글이 없을 경우 + const likeList = await _getLikeList(commentId); + if (likeList.length != 0) { //댓글에 달린 좋아요가 있을 경우 + await Like.destroy({ + where: { + COMMENTID: commentId + } + }, { transaction }); + } + await Comment.destroy({ + where: { + ID: commentId + } + }, { transaction }); + await transaction.commit(); + return responseFormat(200, { message: responseMsg.COMMENT_DELETE_COMPLETE }); + } + // 댓글에 달린 답글이 있을 경우 + await Comment.update({ + CONTENT: "삭제된 댓글입니다." + }, { where: { ID: commentId } - }); - return true; + }, { transaction }); + await transaction.commit(); + return responseFormat(200, { message: responseMsg.COMMENT_DELETE_COMPLETE }); + } catch (err) { + await transaction.rollback(); + return responseFormat(500, { message: responseMsg.COMMENT_DELETE_FAIL }); } - await Comment.update({ - CONTENT: "삭제된 댓글입니다." - }, { - where: { - ID: commentId - } - }); - return true; } -const editComment = async (commentId, content) => { - const targetComment = await Comment.findOne({ - where: { - ID: commentId - } - }); - if (!targetComment) { - return false; - } - await Comment.update({ - CONTENT: content - }, { - where: { - ID: commentId +const editComment = async (userId, medicineId, commentId, content) => { + try { + const targetComment = await Comment.findOne({ + where: { + ID: commentId, + MEDICINEID: medicineId, + } + }); + if (!targetComment) { + return responseFormat(404, { message: responseMsg.COMMENT_NOT_FOUND }); } - }); - return true; -} -const getCommentList = async (medicineId) => { - const commentList = await Comment.findAll({ - where: { - MEDICINEID: medicineId + if (targetComment.USERID != userId) { + return responseFormat(403, { message: responseMsg.COMMENT_EDIT_FAIL }); } - }); - let _commentList = []; - for (let i in commentList) { - let _comment = commentList[i].dataValues; - if (_comment.SUBORDINATION != 0) continue; - _comment.likeList = await getLikeList(_comment.ID); - _comment.replies = []; - _commentList.push(_comment); - } - for (let i in commentList) { - let _comment = commentList[i].dataValues; - if (_comment.SUBORDINATION == 0) continue; - for (let j in _commentList) { - if (_comment.SUBORDINATION == _commentList[j].ID) { - _comment.likeList = await getLikeList(_comment.ID); - _commentList[j].replies.push(_comment); - break; + await Comment.update({ + CONTENT: content + }, { + where: { + ID: commentId, + MEDICINEID: medicineId } - } + }); + return responseFormat(200, { message: responseMsg.COMMENT_EDIT_COMPLETE }); + } + catch (err) { + return responseFormat(500, { message: responseMsg.COMMENT_EDIT_FAIL }); } - return _commentList; } + module.exports = { addLike, removeLike, writeComment, deleteComment, editComment, - getCommentList, - isLiked + isLiked, + getCommentList }; \ No newline at end of file From 3a1fbed296c051213e1667dc4f3e67bb41a34e9f Mon Sep 17 00:00:00 2001 From: winocreative Date: Sat, 3 Jun 2023 18:14:31 +0900 Subject: [PATCH 39/70] =?UTF-8?q?#75=20:=20getCommentId=EC=99=80=20getComm?= =?UTF-8?q?entList=20=EB=B6=84=EB=A6=AC,=20=EC=83=88=EB=A1=9C=EC=9A=B4=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=8C=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/comment/index.js | 13 +++++++++---- server/src/routes/medicine/comment/index.js | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/server/src/controller/comment/index.js b/server/src/controller/comment/index.js index 552890f96..fae8c3db4 100644 --- a/server/src/controller/comment/index.js +++ b/server/src/controller/comment/index.js @@ -7,9 +7,12 @@ const {writeComment, deleteComment, getCommentList, editComment, addLike, remove const get = async (req, res) => { //item_seq, item_name, item_ingr_name, prduct_type, entp_name, spclty_pblc as POST const {ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC} = req.body; - let result = await getMedicineId(ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC); - if (result.code != 200) { return res.status(result.code).send(result.response); } - result = await getCommentList(result.response); + const result = await getMedicineId(ITEM_SEQ, ITEM_NAME, ITEM_INGR_NAME, PRDUCT_TYPE, ENTP_NAME, SPCLTY_PBLC); + return res.status(result.code).send(result.response); +} +const getComment = async (req, res) => { + const {medicineId} = req.query; + const result = await getCommentList(medicineId); return res.status(result.code).send(result.response); } const writeTest = async (req, res) => { @@ -30,7 +33,8 @@ const del = async (req, res) => { return res.status(result.code).send(result.response); } const likeGet = async (req, res) => { - const {commentId, userId} = req.query; + const {commentId} = req.query; + const {userId} = req.verifiedToken; const result = await isLiked(userId, commentId); return res.status(result.code).send(result.response); } @@ -49,6 +53,7 @@ const likeDelete = async (req, res) => { //removeLike module.exports = { get, + getComment, writeTest, patch, del, diff --git a/server/src/routes/medicine/comment/index.js b/server/src/routes/medicine/comment/index.js index 2caa72d60..94422265e 100644 --- a/server/src/routes/medicine/comment/index.js +++ b/server/src/routes/medicine/comment/index.js @@ -6,12 +6,13 @@ const { verifyAccessToken } = require("../../../config/jwt"); // Comment router.post("/writeTest", verifyAccessToken, commentController.writeTest); //CREATE -router.post("/", commentController.get); //READ +router.get("/", commentController.get); //READ +router.get("/:commentId", commentController.getComment); //READ router.patch("/", verifyAccessToken, commentController.patch); //UPDATE router.delete("/", verifyAccessToken, commentController.del); //DELETE // Like -router.get("/like", commentController.likeGet); //READ +router.get("/like", verifyAccessToken, commentController.likeGet); //READ router.post("/like", verifyAccessToken, commentController.likePost); //CREATE router.delete("/like", verifyAccessToken, commentController.likeDelete); //DELETE module.exports = router; \ No newline at end of file From 1591fccacf3fd7d030569878a8fcf819f97cfa68 Mon Sep 17 00:00:00 2001 From: winocreative Date: Sun, 4 Jun 2023 00:50:04 +0900 Subject: [PATCH 40/70] =?UTF-8?q?#75=20:=20recentBrowsed.js=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/jwt.js | 1 + server/src/controller/comment/index.js | 13 +++---- server/src/models/recentBrowsed.js | 41 --------------------- server/src/routes/medicine/comment/index.js | 7 ++-- 4 files changed, 9 insertions(+), 53 deletions(-) delete mode 100644 server/src/models/recentBrowsed.js diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index 03c459faf..eb77a8ff6 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -37,6 +37,7 @@ const verifyAccessToken = (req, res, next) => { const result = responseFormat(401, responseMsg.JWT_INVALID_FORMAT); // 401 unauthorized return res.status(result.code).send(result.response); } + jwt.decode() jwt.verify(token, process.env.JWT_ACCESS_TOKEN_SECRETKEY, (err, data) => { // verifing token if (err) { console.log(err) diff --git a/server/src/controller/comment/index.js b/server/src/controller/comment/index.js index fae8c3db4..c9950525b 100644 --- a/server/src/controller/comment/index.js +++ b/server/src/controller/comment/index.js @@ -11,7 +11,9 @@ const get = async (req, res) => { return res.status(result.code).send(result.response); } const getComment = async (req, res) => { - const {medicineId} = req.query; + const {medicineId} = req.params; + console.log(req); + console.log(medicineId); const result = await getCommentList(medicineId); return res.status(result.code).send(result.response); } @@ -32,19 +34,15 @@ const del = async (req, res) => { const result = await deleteComment(userId, medicineId, commentId); return res.status(result.code).send(result.response); } -const likeGet = async (req, res) => { - const {commentId} = req.query; - const {userId} = req.verifiedToken; - const result = await isLiked(userId, commentId); - return res.status(result.code).send(result.response); -} const likePost = async (req, res) => { //addLike + const {medicineId} = req.params; const {commentId} = req.body; const {userId} = req.verifiedToken; const result = await addLike(userId, commentId); return res.status(result.code).send(result.response); } const likeDelete = async (req, res) => { //removeLike + const {medicineId} = req.params; const {commentId} = req.body; const {userId} = req.verifiedToken; const result = await removeLike(userId, commentId); @@ -57,7 +55,6 @@ module.exports = { writeTest, patch, del, - likeGet, likePost, likeDelete } \ No newline at end of file diff --git a/server/src/models/recentBrowsed.js b/server/src/models/recentBrowsed.js deleted file mode 100644 index 9db1b9b0a..000000000 --- a/server/src/models/recentBrowsed.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; - -module.exports = function (sequelize, DataTypes) { - const RecentBrowsed = sequelize.define('RecentBrowsed', { - ID: { - field: 'ID', - type: DataTypes.INTEGER, - primaryKey: true, - allowNull: false, - defaultValue: 0, - }, - USERID: { - field: 'USER_ID', - type: DataTypes.INTEGER, - allowNull: false - }, - QUERY: { - field: 'QUERY', - type: DataTypes.STRING, - allowNull: false - } - }, { - underscored: true, - freezeTableName: true, - tableName: 'DB_RECENT_BROWSED', - timestamps: true, - hooks: { - beforeCreate: async (recentBrowsed, options) => { // sequence to data id mapping - const result = await sequelize.query('SELECT RECENT_BROWSED_SEQ.NEXTVAL AS ID FROM DUAL', { - type: sequelize.QueryTypes.SELECT - }); - recentBrowsed.ID = result[0].ID; // data 객체의 ID와 DB_RECENT_BROWSED의 ID 매핑 - }, - } - }); - - RecentBrowsed.associate = function (models) { - RecentBrowsed.belongsTo(models.User, {foreignKey: 'USERID', sourceKey: 'ID'}); - } - return RecentBrowsed; -} \ No newline at end of file diff --git a/server/src/routes/medicine/comment/index.js b/server/src/routes/medicine/comment/index.js index 94422265e..c5580fd0d 100644 --- a/server/src/routes/medicine/comment/index.js +++ b/server/src/routes/medicine/comment/index.js @@ -7,12 +7,11 @@ const { verifyAccessToken } = require("../../../config/jwt"); // Comment router.post("/writeTest", verifyAccessToken, commentController.writeTest); //CREATE router.get("/", commentController.get); //READ -router.get("/:commentId", commentController.getComment); //READ +router.get("/:medicineId", commentController.getComment); //READ router.patch("/", verifyAccessToken, commentController.patch); //UPDATE router.delete("/", verifyAccessToken, commentController.del); //DELETE // Like -router.get("/like", verifyAccessToken, commentController.likeGet); //READ -router.post("/like", verifyAccessToken, commentController.likePost); //CREATE -router.delete("/like", verifyAccessToken, commentController.likeDelete); //DELETE +router.post("/:medicineId/like", verifyAccessToken, commentController.likePost); //CREATE +router.delete("/:medicineId/like", verifyAccessToken, commentController.likeDelete); //DELETE module.exports = router; \ No newline at end of file From 07ad25258d84d6d8e9ee5b58d8d9c4853445ee09 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Sun, 4 Jun 2023 05:02:46 +0900 Subject: [PATCH 41/70] =?UTF-8?q?#102=20RecentBrowser=20=EB=AA=A8=EB=8D=B8?= =?UTF-8?q?=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EB=93=A4=EC=97=90=EC=84=9C=20=ED=95=B4=EB=8B=B9=20?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/www.js | 1 - server/src/models/user.js | 1 - 2 files changed, 2 deletions(-) diff --git a/server/bin/www.js b/server/bin/www.js index 5c1ee6e28..673b1662c 100644 --- a/server/bin/www.js +++ b/server/bin/www.js @@ -28,7 +28,6 @@ app.listen(PORT, async () => { console.log("All medicines:", JSON.stringify(await models.Medicine.findAll(), null, 2)); console.log("All likes:", JSON.stringify(await models.Like.findAll(), null, 2)); console.log("All comments:", JSON.stringify(await models.Comment.findAll(), null, 2)); - console.log("All recent browses:", JSON.stringify(await models.RecentBrowsed.findAll(), null, 2)); console.log("All favorite medicines:", JSON.stringify(await models.FavoriteMedicine.findAll(), null, 2)); // // model auto generation test diff --git a/server/src/models/user.js b/server/src/models/user.js index 2c341d042..d0093e198 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -41,7 +41,6 @@ module.exports = function (sequelize, DataTypes) { } }); User.associate = function (models) { - User.hasMany(models.RecentBrowsed, {foreignKey: 'USERID', targetKey: 'ID'}); User.hasMany(models.FavoriteMedicine, {foreignKey: 'USERID', targetKey: 'ID'}); User.hasMany(models.Like, {foreignKey: 'USERID', targetKey: 'ID'}); User.hasMany(models.Comment, {foreignKey: 'USERID', targetKey: 'ID'}); From f2193f7e967a44ed6781c4a67f0ca265e20f5139 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Sun, 4 Jun 2023 05:41:50 +0900 Subject: [PATCH 42/70] =?UTF-8?q?#68=20=EA=B4=80=EC=8B=AC=20=EC=95=BD=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EA=B8=B0=EB=8A=A5=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/jwt.js | 1 - server/src/config/responseMsg.js | 3 ++ .../medicine/favorite/favorite.ctrl.js | 39 +++++++++++++++++++ server/src/routes/medicine/favorite/index.js | 10 +++++ server/src/routes/medicine/index.js | 2 + server/src/routes/user/userRouter.js | 8 ++-- server/src/service/medicineService.js | 23 +++++++++-- server/src/service/userService.js | 4 +- 8 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 server/src/controller/medicine/favorite/favorite.ctrl.js create mode 100644 server/src/routes/medicine/favorite/index.js diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index eb77a8ff6..03c459faf 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -37,7 +37,6 @@ const verifyAccessToken = (req, res, next) => { const result = responseFormat(401, responseMsg.JWT_INVALID_FORMAT); // 401 unauthorized return res.status(result.code).send(result.response); } - jwt.decode() jwt.verify(token, process.env.JWT_ACCESS_TOKEN_SECRETKEY, (err, data) => { // verifing token if (err) { console.log(err) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 7bb4986f8..863b66359 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -30,6 +30,9 @@ module.exports = { COMMENT_EDIT_FAIL: "comment edit fail", // Medicine MEDICINE_ID_FOUND: "medicine id found", + // Medicine_Favorite + MEDICINE_FAVORITE_ADD_COMPLETE: "favorite medicine add complete", + MEDICINE_FAVORITE_ADD_FAIL: "comment write fail", // Like LIKE_ADD_COMPLETE: "like add complete", diff --git a/server/src/controller/medicine/favorite/favorite.ctrl.js b/server/src/controller/medicine/favorite/favorite.ctrl.js new file mode 100644 index 000000000..67d852bca --- /dev/null +++ b/server/src/controller/medicine/favorite/favorite.ctrl.js @@ -0,0 +1,39 @@ +"use strict"; + +const { responseFormat } = require("../../../config/response") +const responseMsg = require("../../../config/responseMsg"); +const { addFavoriteMedicine } = require("../../../service/medicineService"); + +// GET +const output = { + +} + +// POST +const process = { + // Add favorite medicine + // [POST] /medicine/favorite + addFavoriteMedicine: async (req, res) => { + const { userId } = req.verifiedToken; + const { medicineId } = req.body; + const result = await addFavoriteMedicine(userId, medicineId); // add favorite medicine + return res.status(result.code).send(result.response); + } +} + +// PUT +const edit = { + +} + +// DELETE +const eliminate = { + +} + +module.exports = { + output, + process, + edit, + eliminate, +}; \ No newline at end of file diff --git a/server/src/routes/medicine/favorite/index.js b/server/src/routes/medicine/favorite/index.js new file mode 100644 index 000000000..ad44b6ab2 --- /dev/null +++ b/server/src/routes/medicine/favorite/index.js @@ -0,0 +1,10 @@ +"use strict"; + +const router = require("express").Router(); +const favoriteCtrl = require("../../../controller/medicine/favorite/favorite.ctrl"); +const { verifyAccessToken } = require("../../../config/jwt"); + +// Favorite +router.post("/", verifyAccessToken, favoriteCtrl.process.addFavoriteMedicine); // add favorite medicine + +module.exports = router; \ No newline at end of file diff --git a/server/src/routes/medicine/index.js b/server/src/routes/medicine/index.js index af76aed1d..6bb0c9e63 100644 --- a/server/src/routes/medicine/index.js +++ b/server/src/routes/medicine/index.js @@ -2,6 +2,8 @@ const router = require("express").Router(); const commentRouter = require('./comment'); +const favoriteRouter = require('./favorite'); router.use("/comment", commentRouter); +router.use("/favorite", favoriteRouter); // favorite medicine module.exports = router; \ No newline at end of file diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index bf38c77aa..f99ef6e99 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -1,6 +1,6 @@ "use strict"; -const userCrtl = require('../../controller/user/user.ctrl'); +const userCtrl = require('../../controller/user/user.ctrl'); const { verifyRefreshToken } = require("../../config/jwt"); const router = require("express").Router(); @@ -75,9 +75,9 @@ const router = require("express").Router(); * type: string * example: null */ -router.post("/login", userCrtl.process.login); // sign-in +router.post("/login", userCtrl.process.login); // sign-in -router.post("/reissue", verifyRefreshToken, userCrtl.process.reissue); // reissuing token +router.post("/reissue", verifyRefreshToken, userCtrl.process.reissue); // reissuing token /** * @swagger @@ -153,6 +153,6 @@ router.post("/reissue", verifyRefreshToken, userCrtl.process.reissue); // reissu * type: string * example: null */ -router.post("/register", userCrtl.process.register); // sign-up +router.post("/register", userCtrl.process.register); // sign-up module.exports = router; \ No newline at end of file diff --git a/server/src/service/medicineService.js b/server/src/service/medicineService.js index 6ddff5fdf..0e2927383 100644 --- a/server/src/service/medicineService.js +++ b/server/src/service/medicineService.js @@ -1,6 +1,6 @@ "use strict"; -const { Medicine } = require("../models/index"); +const { Medicine, FavoriteMedicine } = require("../models/index"); const { responseFormat } = require("../config/response"); const responseMsg = require("../config/responseMsg"); @@ -25,11 +25,26 @@ const getMedicineId = async (item_seq, item_name, item_ingr_name, prduct_type, e ENTP_NAME: entp_name, SPCLTY_PBLC: spclty_pblc }); - return responseFormat(200, {message: responseMsg.MEDICINE_ID_FOUND, medicineId: newMedicine.ID}); + return responseFormat(200, { message: responseMsg.MEDICINE_ID_FOUND, medicineId: newMedicine.ID }); + } + return responseFormat(200, { message: responseMsg.MEDICINE_ID_FOUND, medicineId: medicine.ID }); +} + +const addFavoriteMedicine = async (user_id, medicine_id) => { + try { + const newFavoriteMedicine = await FavoriteMedicine.create({ // insert new favorite medicine into DB + USERID: user_id, + MEDICINEID: medicine_id + }); + return responseFormat(201, { message: responseMsg.MEDICINE_FAVORITE_ADD_COMPLETE, favoriteMedicineId: newFavoriteMedicine.ID }); // insert SUCCESS + } + catch (err) { + console.log(err); + return responseFormat(500, { message: responseMsg.MEDICINE_FAVORITE_ADD_FAIL }); // insert FAIL } - return responseFormat(200, {message: responseMsg.MEDICINE_ID_FOUND, medicineId: medicine.ID}); } module.exports = { - getMedicineId + getMedicineId, + addFavoriteMedicine } \ No newline at end of file diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 7f8895711..b4f13a500 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -30,8 +30,8 @@ const login = async (email, password) => { } const message = responseMsg.SIGNIN_SUCCESS; // generate response message - const accessToken = createAccessToken(userInfo.USERID); // generate access token - const refreshToken = createRefreshToken(userInfo.USERID); // generate refresh token + const accessToken = createAccessToken(userInfo.ID); // generate access token + const refreshToken = createRefreshToken(userInfo.ID); // generate refresh token return responseFormat(200, tokenResponseFormat(message, accessToken, refreshToken)); } From fa9b89c718469fe8bef70189b38c5d4fbf8d722a Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Sun, 4 Jun 2023 06:29:44 +0900 Subject: [PATCH 43/70] =?UTF-8?q?#68=20=EA=B4=80=EC=8B=AC=20=EC=95=BD=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/jwt.js | 2 -- server/src/config/responseMsg.js | 4 +++ .../medicine/favorite/favorite.ctrl.js | 10 ++++-- server/src/routes/medicine/favorite/index.js | 1 + server/src/service/medicineService.js | 34 ++++++++++++++++++- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/server/src/config/jwt.js b/server/src/config/jwt.js index 03c459faf..2c460e100 100644 --- a/server/src/config/jwt.js +++ b/server/src/config/jwt.js @@ -21,9 +21,7 @@ const createRefreshToken = (userId) => { // resolve token const resolveToken = (req) => { - console.log(req.headers) const token = req.headers[AUTHORIZATION_HEADER] // extract token from http header - console.log(token) if (token && token.startsWith("Bearer ")) { // if token exist return token.substring(7); // return pure token value } diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 863b66359..c7398ebbf 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -31,6 +31,10 @@ module.exports = { // Medicine MEDICINE_ID_FOUND: "medicine id found", // Medicine_Favorite + MEDICINE_FAVORITE_LIST_GET_COMPLETE: "favorite medicine list get complete", + MEDICINE_FAVORITE_LIST_GET_FAIL: "favorite medicine list get fail", + MEDICINE_FAVORITE_GET_COMPLETE: "favorite medicine get complete", + MEDICINE_FAVORITE_GET_FAIL: "favorite medicine get fail", MEDICINE_FAVORITE_ADD_COMPLETE: "favorite medicine add complete", MEDICINE_FAVORITE_ADD_FAIL: "comment write fail", diff --git a/server/src/controller/medicine/favorite/favorite.ctrl.js b/server/src/controller/medicine/favorite/favorite.ctrl.js index 67d852bca..d7b3f123d 100644 --- a/server/src/controller/medicine/favorite/favorite.ctrl.js +++ b/server/src/controller/medicine/favorite/favorite.ctrl.js @@ -2,11 +2,17 @@ const { responseFormat } = require("../../../config/response") const responseMsg = require("../../../config/responseMsg"); -const { addFavoriteMedicine } = require("../../../service/medicineService"); +const { addFavoriteMedicine, getFavoriteMedicineList } = require("../../../service/medicineService"); // GET const output = { - + // GET favorite medicine list + // [GET] /medicine/favorite + getFavoriteMedicineList: async (req, res) => { + const { userId } = req.verifiedToken; + const result = await getFavoriteMedicineList(userId); // get favorite medicine list + return res.status(result.code).send(result.response); + } } // POST diff --git a/server/src/routes/medicine/favorite/index.js b/server/src/routes/medicine/favorite/index.js index ad44b6ab2..3af75b52d 100644 --- a/server/src/routes/medicine/favorite/index.js +++ b/server/src/routes/medicine/favorite/index.js @@ -5,6 +5,7 @@ const favoriteCtrl = require("../../../controller/medicine/favorite/favorite.ctr const { verifyAccessToken } = require("../../../config/jwt"); // Favorite +router.get("/", verifyAccessToken, favoriteCtrl.output.getFavoriteMedicineList); // add favorite medicine router.post("/", verifyAccessToken, favoriteCtrl.process.addFavoriteMedicine); // add favorite medicine module.exports = router; \ No newline at end of file diff --git a/server/src/service/medicineService.js b/server/src/service/medicineService.js index 0e2927383..933674cbe 100644 --- a/server/src/service/medicineService.js +++ b/server/src/service/medicineService.js @@ -30,13 +30,44 @@ const getMedicineId = async (item_seq, item_name, item_ingr_name, prduct_type, e return responseFormat(200, { message: responseMsg.MEDICINE_ID_FOUND, medicineId: medicine.ID }); } +// Search medicine through medicine ID +const getMedicineData = async (ID) => { + const medicine = await Medicine.findOne({ + where: { + ID + } + }); + return medicine.dataValues; +} + +// Get favorite medicine list +const getFavoriteMedicineList = async (user_id) => { + try { + const favorite_medicine_id_list = await FavoriteMedicine.findAll({ // search favorite medicine id list + where: { + USERID: user_id + } + }); + const promises = await favorite_medicine_id_list.map((data) => { // Get medicine data through ID -> promise + return getMedicineData(data.MEDICINEID); + }); + const medicine_list = await Promise.all(promises); // resolve promises + return responseFormat(200, { message: responseMsg.MEDICINE_FAVORITE_LIST_GET_COMPLETE, medicineList: medicine_list }); // search SUCCESS + } + catch (err) { + console.log(err); + return responseFormat(500, { message: responseMsg.MEDICINE_FAVORITE_LIST_GET_FAIL }); // search FAIL + } +} + +// Add favorite medicine const addFavoriteMedicine = async (user_id, medicine_id) => { try { const newFavoriteMedicine = await FavoriteMedicine.create({ // insert new favorite medicine into DB USERID: user_id, MEDICINEID: medicine_id }); - return responseFormat(201, { message: responseMsg.MEDICINE_FAVORITE_ADD_COMPLETE, favoriteMedicineId: newFavoriteMedicine.ID }); // insert SUCCESS + return responseFormat(201, { message: responseMsg.MEDICINE_FAVORITE_ADD_COMPLETE, medicineList: newFavoriteMedicine.ID }); // insert SUCCESS } catch (err) { console.log(err); @@ -46,5 +77,6 @@ const addFavoriteMedicine = async (user_id, medicine_id) => { module.exports = { getMedicineId, + getFavoriteMedicineList, addFavoriteMedicine } \ No newline at end of file From 114c4c9fce6901ac09ef4fd86a49a73e7a29b8b5 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Sun, 4 Jun 2023 06:58:10 +0900 Subject: [PATCH 44/70] =?UTF-8?q?#68=20=EA=B4=80=EC=8B=AC=20=EC=95=BD=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EA=B8=B0=EB=8A=A5=20=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 4 +++- .../medicine/favorite/favorite.ctrl.js | 13 +++++++---- server/src/routes/medicine/favorite/index.js | 1 + server/src/service/medicineService.js | 23 +++++++++++++++++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index c7398ebbf..502b82db4 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -36,7 +36,9 @@ module.exports = { MEDICINE_FAVORITE_GET_COMPLETE: "favorite medicine get complete", MEDICINE_FAVORITE_GET_FAIL: "favorite medicine get fail", MEDICINE_FAVORITE_ADD_COMPLETE: "favorite medicine add complete", - MEDICINE_FAVORITE_ADD_FAIL: "comment write fail", + MEDICINE_FAVORITE_ADD_FAIL: "favorite medicine add fail", + MEDICINE_FAVORITE_DELETE_COMPLETE: "favorite medicine delete complete", + MEDICINE_FAVORITE_DELETE_FAIL: "favorite medicine delete fail", // Like LIKE_ADD_COMPLETE: "like add complete", diff --git a/server/src/controller/medicine/favorite/favorite.ctrl.js b/server/src/controller/medicine/favorite/favorite.ctrl.js index d7b3f123d..51374b65c 100644 --- a/server/src/controller/medicine/favorite/favorite.ctrl.js +++ b/server/src/controller/medicine/favorite/favorite.ctrl.js @@ -1,8 +1,6 @@ "use strict"; -const { responseFormat } = require("../../../config/response") -const responseMsg = require("../../../config/responseMsg"); -const { addFavoriteMedicine, getFavoriteMedicineList } = require("../../../service/medicineService"); +const { addFavoriteMedicine, getFavoriteMedicineList, deleteFavoriteMedicine } = require("../../../service/medicineService"); // GET const output = { @@ -34,7 +32,14 @@ const edit = { // DELETE const eliminate = { - + // Delete favorite medicine + // [DELETE] /medicine/favorite/:medicineId + deleteFavoriteMedicine: async (req, res) => { + const { userId } = req.verifiedToken; + const { medicineId } = req.query; + const result = await deleteFavoriteMedicine(userId, medicineId); // delete favorite medicine + return res.status(result.code).send(result.response); + } } module.exports = { diff --git a/server/src/routes/medicine/favorite/index.js b/server/src/routes/medicine/favorite/index.js index 3af75b52d..ea8837616 100644 --- a/server/src/routes/medicine/favorite/index.js +++ b/server/src/routes/medicine/favorite/index.js @@ -7,5 +7,6 @@ const { verifyAccessToken } = require("../../../config/jwt"); // Favorite router.get("/", verifyAccessToken, favoriteCtrl.output.getFavoriteMedicineList); // add favorite medicine router.post("/", verifyAccessToken, favoriteCtrl.process.addFavoriteMedicine); // add favorite medicine +router.delete("/", verifyAccessToken, favoriteCtrl.eliminate.deleteFavoriteMedicine); // delete favorite medicine module.exports = router; \ No newline at end of file diff --git a/server/src/service/medicineService.js b/server/src/service/medicineService.js index 933674cbe..f67c3a7bf 100644 --- a/server/src/service/medicineService.js +++ b/server/src/service/medicineService.js @@ -67,7 +67,7 @@ const addFavoriteMedicine = async (user_id, medicine_id) => { USERID: user_id, MEDICINEID: medicine_id }); - return responseFormat(201, { message: responseMsg.MEDICINE_FAVORITE_ADD_COMPLETE, medicineList: newFavoriteMedicine.ID }); // insert SUCCESS + return responseFormat(201, { message: responseMsg.MEDICINE_FAVORITE_ADD_COMPLETE, favoriteMedicineID: newFavoriteMedicine.ID }); // insert SUCCESS } catch (err) { console.log(err); @@ -75,8 +75,27 @@ const addFavoriteMedicine = async (user_id, medicine_id) => { } } +// Delete favorite medicine +const deleteFavoriteMedicine = async (user_id, medicine_id) => { + try { + await FavoriteMedicine.destroy({ // delete favorite medicine + where: { + USERID: user_id, + MEDICINEID: medicine_id + } + + }); + return responseFormat(200, { message: responseMsg.MEDICINE_FAVORITE_DELETE_COMPLETE}); // delete SUCCESS + } + catch (err) { + console.log(err); + return responseFormat(500, { message: responseMsg.MEDICINE_FAVORITE_DELETE_FAIL }); // delete FAIL + } +} + module.exports = { getMedicineId, getFavoriteMedicineList, - addFavoriteMedicine + addFavoriteMedicine, + deleteFavoriteMedicine } \ No newline at end of file From d131f718b1760e63933d68d216741837df2963a6 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Sun, 4 Jun 2023 19:12:02 +0900 Subject: [PATCH 45/70] =?UTF-8?q?#105=20=EA=B4=80=EC=8B=AC=20=EC=95=BD=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B0=9C=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../medicine/favorite/favorite.ctrl.js | 36 ++-- server/src/routes/medicine/favorite/index.js | 2 +- server/src/service/medicineService.js | 187 +++++++++++++----- 3 files changed, 159 insertions(+), 66 deletions(-) diff --git a/server/src/controller/medicine/favorite/favorite.ctrl.js b/server/src/controller/medicine/favorite/favorite.ctrl.js index 51374b65c..134d7e302 100644 --- a/server/src/controller/medicine/favorite/favorite.ctrl.js +++ b/server/src/controller/medicine/favorite/favorite.ctrl.js @@ -1,17 +1,31 @@ "use strict"; -const { addFavoriteMedicine, getFavoriteMedicineList, deleteFavoriteMedicine } = require("../../../service/medicineService"); +const { + addFavoriteMedicine, + getFavoriteMedicineList, + deleteFavoriteMedicine, + checkFavoriteMedicine, +} = require("../../../service/medicineService"); // GET const output = { - // GET favorite medicine list + // GET favorite medicine (list) // [GET] /medicine/favorite getFavoriteMedicineList: async (req, res) => { const { userId } = req.verifiedToken; - const result = await getFavoriteMedicineList(userId); // get favorite medicine list + const { ITEM_SEQ } = req.query; + let result; + // If ITEM_SEQ exists -> get favorite medicine + if (ITEM_SEQ) { + result = await checkFavoriteMedicine(userId, ITEM_SEQ); // check favorite medicine + } + // If ITEM_SEQ doesn't exist -> get favorite medicine list + else { + result = await getFavoriteMedicineList(userId); // get favorite medicine list + } return res.status(result.code).send(result.response); } -} +}; // POST const process = { @@ -22,13 +36,11 @@ const process = { const { medicineId } = req.body; const result = await addFavoriteMedicine(userId, medicineId); // add favorite medicine return res.status(result.code).send(result.response); - } -} + }, +}; // PUT -const edit = { - -} +const edit = {}; // DELETE const eliminate = { @@ -39,12 +51,12 @@ const eliminate = { const { medicineId } = req.query; const result = await deleteFavoriteMedicine(userId, medicineId); // delete favorite medicine return res.status(result.code).send(result.response); - } -} + }, +}; module.exports = { output, process, edit, eliminate, -}; \ No newline at end of file +}; diff --git a/server/src/routes/medicine/favorite/index.js b/server/src/routes/medicine/favorite/index.js index ea8837616..ae68367e0 100644 --- a/server/src/routes/medicine/favorite/index.js +++ b/server/src/routes/medicine/favorite/index.js @@ -5,7 +5,7 @@ const favoriteCtrl = require("../../../controller/medicine/favorite/favorite.ctr const { verifyAccessToken } = require("../../../config/jwt"); // Favorite -router.get("/", verifyAccessToken, favoriteCtrl.output.getFavoriteMedicineList); // add favorite medicine +router.get("/", verifyAccessToken, favoriteCtrl.output.getFavoriteMedicineList); // get favorite medicine (list) router.post("/", verifyAccessToken, favoriteCtrl.process.addFavoriteMedicine); // add favorite medicine router.delete("/", verifyAccessToken, favoriteCtrl.eliminate.deleteFavoriteMedicine); // delete favorite medicine diff --git a/server/src/service/medicineService.js b/server/src/service/medicineService.js index f67c3a7bf..6e08ff2b1 100644 --- a/server/src/service/medicineService.js +++ b/server/src/service/medicineService.js @@ -4,98 +4,179 @@ const { Medicine, FavoriteMedicine } = require("../models/index"); const { responseFormat } = require("../config/response"); const responseMsg = require("../config/responseMsg"); -const getMedicineId = async (item_seq, item_name, item_ingr_name, prduct_type, entp_name, spclty_pblc) => { - const medicine = await Medicine.findOne({ - where: { - ITEM_SEQ: item_seq, - ITEM_NAME: item_name, - ITEM_INGR_NAME: item_ingr_name, - PRDUCT_TYPE: prduct_type, - ENTP_NAME: entp_name, - SPCLTY_PBLC: spclty_pblc +const getMedicineId = async ( + ITEM_SEQ, + item_name = null, + item_ingr_name = null, + prduct_type = null, + entp_name = null, + spclty_pblc = null +) => { + // Search medicine ID through ITEM_SEQ + if ( + !( + item_name && + item_ingr_name && + prduct_type && + entp_name && + spclty_pblc + ) + ) { + // Search medicine ID in DB + const medicine = await Medicine.findOne({ + where: { + ITEM_SEQ, + }, + attributes: ["ID"], + }); + return medicine.ID; // return medicine ID + } + // Search medicine ID through ALL PARAMS + else { + const medicine = await Medicine.findOne({ + where: { + ITEM_SEQ, + ITEM_NAME: item_name, + ITEM_INGR_NAME: item_ingr_name, + PRDUCT_TYPE: prduct_type, + ENTP_NAME: entp_name, + SPCLTY_PBLC: spclty_pblc, + }, + }); + if (!medicine) { + //Add medicine data to db + const newMedicine = await Medicine.create({ + ITEM_SEQ, + ITEM_NAME: item_name, + ITEM_INGR_NAME: item_ingr_name, + PRDUCT_TYPE: prduct_type, + ENTP_NAME: entp_name, + SPCLTY_PBLC: spclty_pblc, + }); + return responseFormat(200, { + message: responseMsg.MEDICINE_ID_FOUND, + medicineId: newMedicine.ID, + }); } - }); - if (!medicine) { - //Add medicine data to db - const newMedicine = await Medicine.create({ - ITEM_SEQ: item_seq, - ITEM_NAME: item_name, - ITEM_INGR_NAME: item_ingr_name, - PRDUCT_TYPE: prduct_type, - ENTP_NAME: entp_name, - SPCLTY_PBLC: spclty_pblc + return responseFormat(200, { + message: responseMsg.MEDICINE_ID_FOUND, + medicineId: medicine.ID, }); - return responseFormat(200, { message: responseMsg.MEDICINE_ID_FOUND, medicineId: newMedicine.ID }); } - return responseFormat(200, { message: responseMsg.MEDICINE_ID_FOUND, medicineId: medicine.ID }); -} +}; + +// check favorite medicine +const checkFavoriteMedicine = async (user_id, ITEM_SEQ) => { + try { + // get favorite medicine id + const medicine_id = await getMedicineId(ITEM_SEQ); + + // get favorite medicine + const favorite_medicine = await FavoriteMedicine.findOne({ + where: { + USERID: user_id, + ID: medicine_id, + }, + }); + + let isFavorite = false; + // If favorite medicine exists + if (favorite_medicine) { + isFavorite = true; // isFavorite is true + } + return responseFormat(200, { + message: responseMsg.MEDICINE_FAVORITE_GET_COMPLETE, + isFavorite, + }); + } catch (err) { + console.log(err); + return responseFormat(500, { + message: responseMsg.MEDICINE_FAVORITE_GET_FAIL, + }); // search FAIL + } +}; // Search medicine through medicine ID const getMedicineData = async (ID) => { const medicine = await Medicine.findOne({ where: { - ID - } + ID, + }, }); return medicine.dataValues; -} +}; -// Get favorite medicine list +// Get favorite medicine list const getFavoriteMedicineList = async (user_id) => { try { - const favorite_medicine_id_list = await FavoriteMedicine.findAll({ // search favorite medicine id list + // search favorite medicine id list + const favorite_medicine_id_list = await FavoriteMedicine.findAll({ where: { - USERID: user_id - } + USERID: user_id, + }, }); - const promises = await favorite_medicine_id_list.map((data) => { // Get medicine data through ID -> promise + // Get medicine data through ID -> promise + const promises = await favorite_medicine_id_list.map((data) => { return getMedicineData(data.MEDICINEID); }); const medicine_list = await Promise.all(promises); // resolve promises - return responseFormat(200, { message: responseMsg.MEDICINE_FAVORITE_LIST_GET_COMPLETE, medicineList: medicine_list }); // search SUCCESS - } - catch (err) { + return responseFormat(200, { + message: responseMsg.MEDICINE_FAVORITE_LIST_GET_COMPLETE, + medicineList: medicine_list, + }); // search SUCCESS + } catch (err) { console.log(err); - return responseFormat(500, { message: responseMsg.MEDICINE_FAVORITE_LIST_GET_FAIL }); // search FAIL + return responseFormat(500, { + message: responseMsg.MEDICINE_FAVORITE_LIST_GET_FAIL, + }); // search FAIL } -} +}; // Add favorite medicine const addFavoriteMedicine = async (user_id, medicine_id) => { try { - const newFavoriteMedicine = await FavoriteMedicine.create({ // insert new favorite medicine into DB + // insert new favorite medicine into DB + const newFavoriteMedicine = await FavoriteMedicine.create({ USERID: user_id, - MEDICINEID: medicine_id + MEDICINEID: medicine_id, }); - return responseFormat(201, { message: responseMsg.MEDICINE_FAVORITE_ADD_COMPLETE, favoriteMedicineID: newFavoriteMedicine.ID }); // insert SUCCESS - } - catch (err) { + return responseFormat(201, { + message: responseMsg.MEDICINE_FAVORITE_ADD_COMPLETE, + favoriteMedicineID: newFavoriteMedicine.ID, + }); // insert SUCCESS + } catch (err) { console.log(err); - return responseFormat(500, { message: responseMsg.MEDICINE_FAVORITE_ADD_FAIL }); // insert FAIL + return responseFormat(500, { + message: responseMsg.MEDICINE_FAVORITE_ADD_FAIL, + }); // insert FAIL } -} +}; // Delete favorite medicine const deleteFavoriteMedicine = async (user_id, medicine_id) => { try { - await FavoriteMedicine.destroy({ // delete favorite medicine + // delete favorite medicine + await FavoriteMedicine.destroy({ where: { USERID: user_id, - MEDICINEID: medicine_id - } - + MEDICINEID: medicine_id, + }, }); - return responseFormat(200, { message: responseMsg.MEDICINE_FAVORITE_DELETE_COMPLETE}); // delete SUCCESS - } - catch (err) { + return responseFormat(200, { + message: responseMsg.MEDICINE_FAVORITE_DELETE_COMPLETE, + }); // delete SUCCESS + } catch (err) { console.log(err); - return responseFormat(500, { message: responseMsg.MEDICINE_FAVORITE_DELETE_FAIL }); // delete FAIL + return responseFormat(500, { + message: responseMsg.MEDICINE_FAVORITE_DELETE_FAIL, + }); // delete FAIL } -} +}; module.exports = { getMedicineId, getFavoriteMedicineList, addFavoriteMedicine, - deleteFavoriteMedicine -} \ No newline at end of file + deleteFavoriteMedicine, + checkFavoriteMedicine, +}; From d358017637fefedd10394d3610effb3c9eb07ae3 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Sun, 4 Jun 2023 20:41:59 +0900 Subject: [PATCH 46/70] =?UTF-8?q?#108=20=ED=86=A0=ED=81=B0=20=EC=9E=AC?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20API=20=EB=B0=98=ED=99=98=EA=B0=92=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/userService.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/service/userService.js b/server/src/service/userService.js index b4f13a500..447823e19 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -80,10 +80,10 @@ const createUser = async (email, password, nickname) => { // reissue token const reissueToken = (userId) => { - const response = responseMsg.REISSUE_SUCCESS; - response.accessToken = createAccessToken(userId); // generate access token - response.refreshToken = createRefreshToken(userId); // generate refresh token - return responseFormat(200, response); + const message = responseMsg.REISSUE_SUCCESS; + const accessToken = createAccessToken(userId); // generate access token + const refreshToken = createRefreshToken(userId); // generate refresh token + return responseFormat(200, tokenResponseFormat(message, accessToken, refreshToken)); } module.exports = { From d73402b26155df14875d05cecce91c5f9cb59229 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 5 Jun 2023 21:06:06 +0900 Subject: [PATCH 47/70] =?UTF-8?q?#113=20=EC=9C=A0=EC=A0=80=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EB=B3=80=EA=B2=BD=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 7 +++++- server/src/controller/user/user.ctrl.js | 11 +++++++-- server/src/routes/user/userRouter.js | 3 ++- server/src/service/userService.js | 31 +++++++++++++++++++++---- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 502b82db4..de8e62c53 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -1,6 +1,7 @@ "use strict"; module.exports = { + // USER // Success SIGNIN_SUCCESS: "login success", SIGNUP_SUCCESS: "new user created", @@ -14,11 +15,15 @@ module.exports = { SIGNUP_BAD_REQUEST: "paramter must include 'email(string), password(string), nickname(string)'", // Response error - SIGNUP_DUPLICATE_PARAMETER: (parameter) => { + DUPLICATE_PARAMETER: (parameter) => { return `the ${parameter} is already in use` }, SIGNUP_INTERNAL_SERVER_ERROR: "server error", + // USERINFO + USER_UPDATE_NICKNAME_COMPLETE: "user nickname update complete", + USER_UPDATE_NICKNAME_FAIL: "user nickname update fail", + // Comment COMMENT_GET_COMPLETE: "comment get complete", COMMENT_WRITE_COMPLETE: "comment write complete", diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 21217d80b..8e08c5939 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -2,7 +2,7 @@ const { responseFormat } = require("../../config/response") const responseMsg = require("../../config/responseMsg"); -const { login, createUser, reissueToken } = require("../../service/userService"); +const { login, createUser, reissueToken, updateUserNickname } = require("../../service/userService"); // GET const output = { @@ -43,7 +43,14 @@ const process = { // PUT const edit = { - + // Edit user nickname + // [PATCH] /user + patchUserNickname: async (req, res) => { + const { userId } = req.verifiedToken; + const { newNickname } = req.body; + const result = await updateUserNickname(userId, newNickname); // update user nickname + return res.status(result.code).send(result.response); + } } // DELETE diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index f99ef6e99..9f58ed616 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -1,7 +1,7 @@ "use strict"; const userCtrl = require('../../controller/user/user.ctrl'); -const { verifyRefreshToken } = require("../../config/jwt"); +const { verifyRefreshToken, verifyAccessToken } = require("../../config/jwt"); const router = require("express").Router(); /** @@ -154,5 +154,6 @@ router.post("/reissue", verifyRefreshToken, userCtrl.process.reissue); // reissu * example: null */ router.post("/register", userCtrl.process.register); // sign-up +router.patch("/", verifyAccessToken, userCtrl.edit.patchUserNickname) // edit user nickname module.exports = router; \ No newline at end of file diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 447823e19..500020c19 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -28,7 +28,7 @@ const login = async (email, password) => { if (password != userInfo.PASSWORD) { // password mismatch return responseFormat(401, tokenResponseFormat(responseMsg.SIGNIN_PASSWORD_MISMATCH)); } - + const message = responseMsg.SIGNIN_SUCCESS; // generate response message const accessToken = createAccessToken(userInfo.ID); // generate access token const refreshToken = createRefreshToken(userInfo.ID); // generate refresh token @@ -51,11 +51,11 @@ const createUser = async (email, password, nickname) => { // duplicate check let checkParam = "EMAIL" if (await duplicateCheck({ [checkParam]: email })) { // email - return responseFormat(409, tokenResponseFormat(responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam))); + return responseFormat(409, tokenResponseFormat(responseMsg.DUPLICATE_PARAMETER(checkParam))); } checkParam = "NICKNAME"; if (await duplicateCheck({ [checkParam]: nickname })) { // nickname - return responseFormat(409, tokenResponseFormat(responseMsg.SIGNUP_DUPLICATE_PARAMETER(checkParam))); + return responseFormat(409, tokenResponseFormat(responseMsg.DUPLICATE_PARAMETER(checkParam))); } try { @@ -64,7 +64,7 @@ const createUser = async (email, password, nickname) => { PASSWORD: password, NICKNAME: nickname }); - + const message = responseMsg.SIGNUP_SUCCESS; // generate response message const accessToken = createAccessToken(user.ID); // generate access token const refreshToken = createRefreshToken(user.ID); // generate refresh token @@ -86,8 +86,29 @@ const reissueToken = (userId) => { return responseFormat(200, tokenResponseFormat(message, accessToken, refreshToken)); } +// update user nickname +const updateUserNickname = async (user_id, new_nickname) => { + // nickname duplicate check + if (await duplicateCheck({ NICKNAME: new_nickname })) { + return responseFormat(409, responseMsg.DUPLICATE_PARAMETER("NICKNAME")); + } + try { + // update user nickname + await User.update( + { NICKNAME: new_nickname }, + { where: { ID: user_id } } + ); + return responseFormat(200, { message: responseMsg.USER_UPDATE_NICKNAME_COMPLETE }); + } + catch (err) { + console.log(err); + return responseFormat(500, { message: responseMsg.USER_UPDATE_NICKNAME_FAIL }); + } +} + module.exports = { login, createUser, - reissueToken + reissueToken, + updateUserNickname } \ No newline at end of file From c1d056bfb9882f329e337fed5448d81b23363ced Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 5 Jun 2023 21:37:25 +0900 Subject: [PATCH 48/70] =?UTF-8?q?#113=20=EC=9C=A0=EC=A0=80=20=EB=B9=84?= =?UTF-8?q?=EB=B0=80=EB=B2=88=ED=98=B8=20=EB=B3=80=EA=B2=BD=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 10 ++++++--- server/src/controller/user/user.ctrl.js | 10 ++++----- server/src/routes/user/userRouter.js | 2 +- server/src/service/userService.js | 29 ++++++++++++++++--------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index de8e62c53..c70d02c61 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -16,13 +16,17 @@ module.exports = { // Response error DUPLICATE_PARAMETER: (parameter) => { - return `the ${parameter} is already in use` + return `the ${parameter} is already in use`; }, SIGNUP_INTERNAL_SERVER_ERROR: "server error", // USERINFO - USER_UPDATE_NICKNAME_COMPLETE: "user nickname update complete", - USER_UPDATE_NICKNAME_FAIL: "user nickname update fail", + USER_UPDATE_COMPLETE: (parameter) => { + return `user ${parameter} update complete`; + }, + USER_UPDATE_FAIL: (parameter) => { + return `user ${parameter} update fail`; + }, // Comment COMMENT_GET_COMPLETE: "comment get complete", diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 8e08c5939..dbf294cf3 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -2,7 +2,7 @@ const { responseFormat } = require("../../config/response") const responseMsg = require("../../config/responseMsg"); -const { login, createUser, reissueToken, updateUserNickname } = require("../../service/userService"); +const { login, createUser, reissueToken, updateUserInfo } = require("../../service/userService"); // GET const output = { @@ -43,12 +43,12 @@ const process = { // PUT const edit = { - // Edit user nickname + // Edit user nickname/password // [PATCH] /user - patchUserNickname: async (req, res) => { + patchUserInfo: async (req, res) => { const { userId } = req.verifiedToken; - const { newNickname } = req.body; - const result = await updateUserNickname(userId, newNickname); // update user nickname + const { newNickname, newPassword } = req.body; + const result = await updateUserInfo(userId, newNickname, newPassword); // update user nickname or password return res.status(result.code).send(result.response); } } diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index 9f58ed616..7c3e79576 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -154,6 +154,6 @@ router.post("/reissue", verifyRefreshToken, userCtrl.process.reissue); // reissu * example: null */ router.post("/register", userCtrl.process.register); // sign-up -router.patch("/", verifyAccessToken, userCtrl.edit.patchUserNickname) // edit user nickname +router.patch("/", verifyAccessToken, userCtrl.edit.patchUserInfo) // edit user information module.exports = router; \ No newline at end of file diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 500020c19..0257c55f6 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -86,23 +86,32 @@ const reissueToken = (userId) => { return responseFormat(200, tokenResponseFormat(message, accessToken, refreshToken)); } -// update user nickname -const updateUserNickname = async (user_id, new_nickname) => { - // nickname duplicate check - if (await duplicateCheck({ NICKNAME: new_nickname })) { - return responseFormat(409, responseMsg.DUPLICATE_PARAMETER("NICKNAME")); +// update user information +const updateUserInfo = async (user_id, new_nickname, new_password) => { + let updateCondition, checkParam; + if (new_nickname && !new_password) { // update user nickname + checkParam = "NICKNAME"; + updateCondition = { [checkParam]: new_nickname }; + // nickname duplicate check + if (await duplicateCheck(updateCondition)) { + return responseFormat(409, responseMsg.DUPLICATE_PARAMETER(checkParam)); + } + } else if (!new_nickname && new_password) { // update user password + checkParam = "PASSWORD"; + updateCondition = { [checkParam]: new_password }; } + try { - // update user nickname + // update user information await User.update( - { NICKNAME: new_nickname }, + updateCondition, { where: { ID: user_id } } ); - return responseFormat(200, { message: responseMsg.USER_UPDATE_NICKNAME_COMPLETE }); + return responseFormat(200, { message: responseMsg.USER_UPDATE_COMPLETE(checkParam) }); } catch (err) { console.log(err); - return responseFormat(500, { message: responseMsg.USER_UPDATE_NICKNAME_FAIL }); + return responseFormat(500, { message: responseMsg.USER_UPDATE_FAIL(checkParam) }); } } @@ -110,5 +119,5 @@ module.exports = { login, createUser, reissueToken, - updateUserNickname + updateUserInfo } \ No newline at end of file From 444a2138f0cf4bab9cc743ef6127ba658d366356 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Mon, 5 Jun 2023 21:48:08 +0900 Subject: [PATCH 49/70] =?UTF-8?q?#113=20=EC=9C=A0=EC=A0=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 3 +++ server/src/controller/user/user.ctrl.js | 10 ++++++++-- server/src/routes/user/userRouter.js | 1 + server/src/service/userService.js | 20 +++++++++++++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index c70d02c61..04a386ff0 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -27,6 +27,9 @@ module.exports = { USER_UPDATE_FAIL: (parameter) => { return `user ${parameter} update fail`; }, + USER_DELETE_COMPLETE: "user delete complete", + USER_DELETE_FAIL: "user delete fail", + // Comment COMMENT_GET_COMPLETE: "comment get complete", diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index dbf294cf3..cf1b00df1 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -2,7 +2,7 @@ const { responseFormat } = require("../../config/response") const responseMsg = require("../../config/responseMsg"); -const { login, createUser, reissueToken, updateUserInfo } = require("../../service/userService"); +const { login, createUser, reissueToken, updateUserInfo, deleteUser } = require("../../service/userService"); // GET const output = { @@ -55,7 +55,13 @@ const edit = { // DELETE const eliminate = { - + // Delete user + // [DELETE] /user + deleteUser: async (req, res) => { + const { userId } = req.verifiedToken; + const result = await deleteUser(userId); // delete user + return res.status(result.code).send(result.response); + } } module.exports = { diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index 7c3e79576..23a1330a0 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -155,5 +155,6 @@ router.post("/reissue", verifyRefreshToken, userCtrl.process.reissue); // reissu */ router.post("/register", userCtrl.process.register); // sign-up router.patch("/", verifyAccessToken, userCtrl.edit.patchUserInfo) // edit user information +router.delete("/", verifyAccessToken, userCtrl.eliminate.deleteUser) // delete user module.exports = router; \ No newline at end of file diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 0257c55f6..b08e9d871 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -115,9 +115,27 @@ const updateUserInfo = async (user_id, new_nickname, new_password) => { } } +// delete user +const deleteUser = async (user_id) => { + try { + // delete user + await User.destroy( + { where: { ID: user_id } } + ); + return responseFormat(200, { + message: responseMsg.USER_DELETE_COMPLETE, + }); // delete SUCCESS + } + catch (err) { + console.log(err); + return responseFormat(500, { message: responseMsg.USER_DELETE_FAIL }); + } +} + module.exports = { login, createUser, reissueToken, - updateUserInfo + updateUserInfo, + deleteUser } \ No newline at end of file From dc03983701addfb7a5a547ee51e2034568341870 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Jun 2023 22:34:26 +0900 Subject: [PATCH 50/70] =?UTF-8?q?#75=20:=20UserService=EC=97=90=20=5FgetUs?= =?UTF-8?q?erNickname=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/commentService.js | 4 +++- server/src/service/userService.js | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index 42a7def4d..8d04ee391 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -3,7 +3,7 @@ const { Comment, Like } = require("../models/index"); const { responseFormat } = require("../config/response"); const responseMsg = require("../config/responseMsg"); - +const {_getUserNickname} = require("./userService"); const _getLikeList = async (commentId) => { //NOT FOR EXPORT try { const likeList = await Like.findAll({ @@ -31,6 +31,7 @@ const _getCommentList = async (medicineId) => { //NOT FOR EXPORT let _comment = commentList[i].dataValues; if (_comment.SUBORDINATION != 0) continue; _comment.likeList = await _getLikeList(_comment.ID); + _comment.nickname = await _getUserNickname(_comment.USERID); _comment.replies = []; _commentList.push(_comment); } @@ -39,6 +40,7 @@ const _getCommentList = async (medicineId) => { //NOT FOR EXPORT if (_comment.SUBORDINATION == 0) continue; for (let j in _commentList) { if (_comment.SUBORDINATION == _commentList[j].ID) { + _comment.nickname = await _getUserNickname(_comment.USERID); _comment.likeList = await _getLikeList(_comment.ID); _commentList[j].replies.push(_comment); break; diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 447823e19..ecf0a1b2c 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -13,7 +13,19 @@ const tokenResponseFormat = (message, access_token = null, refresh_token = null) refresh_token } } - +const _getUserNickname = async (userId) => { //NOT FOR EXPORT + try { + const user = await User.findOne({ + attributes: ["NICKNAME"], + where: { + ID: userId + } + }); + return user.NICKNAME; + } catch (err) { + return null; + } +} // sign-in const login = async (email, password) => { const userInfo = await User.findOne({ @@ -87,6 +99,7 @@ const reissueToken = (userId) => { } module.exports = { + _getUserNickname, login, createUser, reissueToken From 79e8620c0860c9151cabce2002ddb684e9a974db Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Tue, 6 Jun 2023 18:05:54 +0900 Subject: [PATCH 51/70] =?UTF-8?q?#117=20=EC=9D=98=EC=95=BD=ED=92=88=20ID?= =?UTF-8?q?=20=EB=B0=98=ED=99=98=20API=EC=9D=98=20HTTP=20method=20POST?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/routes/medicine/comment/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/routes/medicine/comment/index.js b/server/src/routes/medicine/comment/index.js index c5580fd0d..768c97e58 100644 --- a/server/src/routes/medicine/comment/index.js +++ b/server/src/routes/medicine/comment/index.js @@ -6,7 +6,7 @@ const { verifyAccessToken } = require("../../../config/jwt"); // Comment router.post("/writeTest", verifyAccessToken, commentController.writeTest); //CREATE -router.get("/", commentController.get); //READ +router.post("/", commentController.get); //READ -> The function to get the medicine id, but the http body exists, so use post router.get("/:medicineId", commentController.getComment); //READ router.patch("/", verifyAccessToken, commentController.patch); //UPDATE router.delete("/", verifyAccessToken, commentController.del); //DELETE From d0ae7eaf5fb103de23f69bc0d505cf4c30e49d63 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 7 Jun 2023 17:29:11 +0900 Subject: [PATCH 52/70] =?UTF-8?q?#122=20=EC=9C=A0=EC=A0=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=B0=98=ED=99=98=20API=20=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/responseMsg.js | 2 ++ server/src/controller/user/user.ctrl.js | 9 ++++++++- server/src/routes/user/userRouter.js | 1 + server/src/service/userService.js | 24 +++++++++++++++++++++++- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/server/src/config/responseMsg.js b/server/src/config/responseMsg.js index 04a386ff0..6e8de81a5 100644 --- a/server/src/config/responseMsg.js +++ b/server/src/config/responseMsg.js @@ -15,6 +15,8 @@ module.exports = { SIGNUP_BAD_REQUEST: "paramter must include 'email(string), password(string), nickname(string)'", // Response error + USER_GET_COMPLETE: "user information get complete", + USER_GET_FAIL: "user information get fail", DUPLICATE_PARAMETER: (parameter) => { return `the ${parameter} is already in use`; }, diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index cf1b00df1..2bcb627b1 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -2,10 +2,17 @@ const { responseFormat } = require("../../config/response") const responseMsg = require("../../config/responseMsg"); -const { login, createUser, reissueToken, updateUserInfo, deleteUser } = require("../../service/userService"); +const { login, createUser, reissueToken, updateUserInfo, deleteUser, getUserInfo } = require("../../service/userService"); // GET const output = { + // GET user info + // [GET] /user + getUserInfo: async (req, res) => { + const { userId } = req.verifiedToken; + const result = await getUserInfo(userId); // get user info + return res.status(result.code).send(result.response); + } } // POST diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index 23a1330a0..fbb839b7f 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -154,6 +154,7 @@ router.post("/reissue", verifyRefreshToken, userCtrl.process.reissue); // reissu * example: null */ router.post("/register", userCtrl.process.register); // sign-up +router.get("/", verifyAccessToken, userCtrl.output.getUserInfo) // get user information router.patch("/", verifyAccessToken, userCtrl.edit.patchUserInfo) // edit user information router.delete("/", verifyAccessToken, userCtrl.eliminate.deleteUser) // delete user diff --git a/server/src/service/userService.js b/server/src/service/userService.js index b6e6746b7..599a6f741 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -58,6 +58,27 @@ const duplicateCheck = async (parameter) => { return false; // if user not exists } +// get user info +const getUserInfo = async (user_id) => { + try { + // get user + const user = (await User.findOne({ + attributes: ["ID", "EMAIL", "NICKNAME"], + where: { ID: user_id } + })).dataValues; + return responseFormat(200, { + userId: user.ID, + email: user.EMAIL, + nickname: user.NICKNAME, + message: responseMsg.USER_GET_COMPLETE, + }); // get user SUCCESS + } + catch (err) { + console.log(err); + return responseFormat(500, { message: responseMsg.USER_GET_FAIL }); + } +} + // create user const createUser = async (email, password, nickname) => { // duplicate check @@ -150,5 +171,6 @@ module.exports = { createUser, reissueToken, updateUserInfo, - deleteUser + deleteUser, + getUserInfo } \ No newline at end of file From 3d33b2c5461f83cfd76ecb6a6539c119d6128d73 Mon Sep 17 00:00:00 2001 From: ho-sick99 Date: Wed, 7 Jun 2023 18:01:31 +0900 Subject: [PATCH 53/70] =?UTF-8?q?#124=20=EB=A1=9C=EA=B7=B8=EC=9D=B8,=20?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20API=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=EA=B0=92=EC=97=90=20=EC=9C=A0=EC=A0=80=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=ED=8F=AC=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/userService.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 599a6f741..ce14c6fe3 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -6,8 +6,11 @@ const responseMsg = require("../config/responseMsg"); const { createAccessToken, createRefreshToken } = require("../config/jwt"); // sign-in response format -const tokenResponseFormat = (message, access_token = null, refresh_token = null) => { +const tokenResponseFormat = (message, userId = null, nickname = null, email = null, access_token = null, refresh_token = null) => { return { + userId, + nickname, + email, message, access_token, refresh_token @@ -28,24 +31,24 @@ const _getUserNickname = async (userId) => { //NOT FOR EXPORT } // sign-in const login = async (email, password) => { - const userInfo = await User.findOne({ - attributes: ["ID", "PASSWORD"], + const user = await User.findOne({ + attributes: ["ID", "PASSWORD", "NICKNAME", "EMAIL"], where: { EMAIL: email } }); - if (!userInfo) { // if user not exists + if (!user) { // if user not exists return responseFormat(404, tokenResponseFormat(responseMsg.SIGNIN_USER_NOT_FOUND)); } - if (password != userInfo.PASSWORD) { // password mismatch + if (password != user.PASSWORD) { // password mismatch return responseFormat(401, tokenResponseFormat(responseMsg.SIGNIN_PASSWORD_MISMATCH)); } const message = responseMsg.SIGNIN_SUCCESS; // generate response message - const accessToken = createAccessToken(userInfo.ID); // generate access token - const refreshToken = createRefreshToken(userInfo.ID); // generate refresh token + const accessToken = createAccessToken(user.ID); // generate access token + const refreshToken = createRefreshToken(user.ID); // generate refresh token - return responseFormat(200, tokenResponseFormat(message, accessToken, refreshToken)); + return responseFormat(200, tokenResponseFormat(message, user.ID, user.NICKNAME, user.EMAIL, accessToken, refreshToken)); } // duplicate check @@ -102,7 +105,7 @@ const createUser = async (email, password, nickname) => { const accessToken = createAccessToken(user.ID); // generate access token const refreshToken = createRefreshToken(user.ID); // generate refresh token - return responseFormat(201, tokenResponseFormat(message, accessToken, refreshToken)); + return responseFormat(201, tokenResponseFormat(message, user.ID, user.NICKNAME, user.EMAIL, accessToken, refreshToken)); } catch (err) { From d0a5f91fa4dad0ec3152e4239b7282d7049173f9 Mon Sep 17 00:00:00 2001 From: winocreative Date: Wed, 7 Jun 2023 23:38:17 +0900 Subject: [PATCH 54/70] =?UTF-8?q?#129=20:=20userRouter=EC=97=90=20getComme?= =?UTF-8?q?ntListFromUserId=20=EB=9D=BC=EC=9A=B0=ED=8C=85->=ED=86=A0?= =?UTF-8?q?=ED=81=B0=EC=9C=BC=EB=A1=9C=20=EB=8C=93=EA=B8=80=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/user/user.ctrl.js | 7 ++++++- server/src/routes/user/userRouter.js | 3 +-- server/src/service/commentService.js | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 2bcb627b1..4e712212e 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -3,7 +3,7 @@ const { responseFormat } = require("../../config/response") const responseMsg = require("../../config/responseMsg"); const { login, createUser, reissueToken, updateUserInfo, deleteUser, getUserInfo } = require("../../service/userService"); - +const { getCommentListFromUserId } = require("../../service/commentService"); // GET const output = { // GET user info @@ -12,6 +12,11 @@ const output = { const { userId } = req.verifiedToken; const result = await getUserInfo(userId); // get user info return res.status(result.code).send(result.response); + }, + getCommentListFromUserId: async (req, res) => { + const { userId } = req.verifiedToken; + const result = await getCommentListFromUserId(userId); // get user info + return res.status(result.code).send(result.response); } } diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index fbb839b7f..d1418015d 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -3,7 +3,6 @@ const userCtrl = require('../../controller/user/user.ctrl'); const { verifyRefreshToken, verifyAccessToken } = require("../../config/jwt"); const router = require("express").Router(); - /** * @swagger * /user/login: @@ -157,5 +156,5 @@ router.post("/register", userCtrl.process.register); // sign-up router.get("/", verifyAccessToken, userCtrl.output.getUserInfo) // get user information router.patch("/", verifyAccessToken, userCtrl.edit.patchUserInfo) // edit user information router.delete("/", verifyAccessToken, userCtrl.eliminate.deleteUser) // delete user - +router.get("/comment", verifyAccessToken, userCtrl.output.getCommentListFromUserId); module.exports = router; \ No newline at end of file diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index 8d04ee391..d8bc0beaf 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -177,6 +177,8 @@ const editComment = async (userId, medicineId, commentId, content) => { return responseFormat(404, { message: responseMsg.COMMENT_NOT_FOUND }); } if (targetComment.USERID != userId) { + console.log('userId: ', userId); + console.log('targetComment.USERID: ', targetComment.USERID); return responseFormat(403, { message: responseMsg.COMMENT_EDIT_FAIL }); } await Comment.update({ From f096fa1b9ad39d89f9fbdaf9f7323c9362bc2d0b Mon Sep 17 00:00:00 2001 From: winocreative Date: Wed, 7 Jun 2023 23:49:55 +0900 Subject: [PATCH 55/70] =?UTF-8?q?#133=20:=20=EC=8B=A4=EC=A0=9C=EB=A1=9C=20?= =?UTF-8?q?DB=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A5=BC=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0,=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=EB=A7=8C=20=EB=AA=BB=ED=95=98=EA=B2=8C=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/userService.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/service/userService.js b/server/src/service/userService.js index ce14c6fe3..e82c60760 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -154,8 +154,12 @@ const updateUserInfo = async (user_id, new_nickname, new_password) => { // delete user const deleteUser = async (user_id) => { try { - // delete user - await User.destroy( + // update email with destroyed_{user_id}, nickname with 알수없음_{user_id} + const updated = await User.update( + { + EMAIL: `destroyed_${user_id}`, + NICKNAME: `알수없음_${user_id}` + }, { where: { ID: user_id } } ); return responseFormat(200, { From 3c47c88cd8fd4249a661c998ce68e8e1571895ab Mon Sep 17 00:00:00 2001 From: winocreative Date: Thu, 8 Jun 2023 00:42:11 +0900 Subject: [PATCH 56/70] =?UTF-8?q?#137=20:=20tokenResponseFormat=20?= =?UTF-8?q?=EC=88=98=EC=A0=95'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/user/user.ctrl.js | 1 + server/src/service/commentService.js | 18 +++++++++++++++++- server/src/service/userService.js | 18 +++++++++--------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index 2bcb627b1..3177f9858 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -44,6 +44,7 @@ const process = { reissue: (req, res) => { const { userId } = req.verifiedToken; const result = reissueToken(userId); // reissuing token + console.log(result); return res.status(result.code).send(result.response); } } diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index 8d04ee391..e4a919b80 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -67,6 +67,19 @@ const getCommentList = async (medicineId) => { const commentList = await _getCommentList(medicineId); return responseFormat(200, { message: responseMsg.COMMENT_GET_COMPLETE, commentList: commentList }); } +const getCommentListFromUserId = async (userId) => { + const commentList = await Comment.findAll({ + where: { + USERID: userId + } + }); + let _commentList = []; + for (let i in commentList) { + let _comment = commentList[i].dataValues; + _commentList.push(_comment); + } + return responseFormat(200, { message: responseMsg.COMMENT_GET_COMPLETE, commentList: _commentList }); +} const addLike = async (userId, commentId) => { try { const newLike = await Like.create({ @@ -177,6 +190,8 @@ const editComment = async (userId, medicineId, commentId, content) => { return responseFormat(404, { message: responseMsg.COMMENT_NOT_FOUND }); } if (targetComment.USERID != userId) { + console.log('userId: ', userId); + console.log('targetComment.USERID: ', targetComment.USERID); return responseFormat(403, { message: responseMsg.COMMENT_EDIT_FAIL }); } await Comment.update({ @@ -202,5 +217,6 @@ module.exports = { deleteComment, editComment, isLiked, - getCommentList + getCommentList, + getCommentListFromUserId }; \ No newline at end of file diff --git a/server/src/service/userService.js b/server/src/service/userService.js index ce14c6fe3..333035618 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -7,14 +7,14 @@ const { createAccessToken, createRefreshToken } = require("../config/jwt"); // sign-in response format const tokenResponseFormat = (message, userId = null, nickname = null, email = null, access_token = null, refresh_token = null) => { - return { - userId, - nickname, - email, - message, - access_token, - refresh_token - } + let struct = {}; + struct.message = message; + if (userId) struct.userId = userId; + if (nickname) struct.nickname = nickname; + if (email) struct.email = email; + if (access_token) struct.access_token = access_token; + if (refresh_token) struct.refresh_token = refresh_token; + return struct; } const _getUserNickname = async (userId) => { //NOT FOR EXPORT try { @@ -119,7 +119,7 @@ const reissueToken = (userId) => { const message = responseMsg.REISSUE_SUCCESS; const accessToken = createAccessToken(userId); // generate access token const refreshToken = createRefreshToken(userId); // generate refresh token - return responseFormat(200, tokenResponseFormat(message, accessToken, refreshToken)); + return responseFormat(200, tokenResponseFormat(message, null, null, null, accessToken, refreshToken)); } // update user information From 5429ebf4635a05a6892d8ea6028299e5a40637b1 Mon Sep 17 00:00:00 2001 From: winocreative Date: Thu, 8 Jun 2023 01:54:11 +0900 Subject: [PATCH 57/70] =?UTF-8?q?Hotfix=20:=20=EC=95=88=EB=93=9C=EB=A1=9C?= =?UTF-8?q?=EC=9D=B4=EB=93=9C=20http=EC=9A=94=EC=B2=AD=EC=97=90=EC=84=9C?= =?UTF-8?q?=20Delete=EC=97=90=20body=EB=A5=BC=20=EB=AA=BB=EB=84=A3?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=8C=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/comment/index.js | 5 ++--- server/src/routes/medicine/comment/index.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/controller/comment/index.js b/server/src/controller/comment/index.js index c9950525b..59be0acdf 100644 --- a/server/src/controller/comment/index.js +++ b/server/src/controller/comment/index.js @@ -29,7 +29,7 @@ const patch = async (req, res) => { return res.status(result.code).send(result.response); } const del = async (req, res) => { - const {medicineId, commentId} = req.body; + const {medicineId, commentId} = req.params; const {userId} = req.verifiedToken; const result = await deleteComment(userId, medicineId, commentId); return res.status(result.code).send(result.response); @@ -42,8 +42,7 @@ const likePost = async (req, res) => { //addLike return res.status(result.code).send(result.response); } const likeDelete = async (req, res) => { //removeLike - const {medicineId} = req.params; - const {commentId} = req.body; + const {medicineId, commentId} = req.params; const {userId} = req.verifiedToken; const result = await removeLike(userId, commentId); return res.status(result.code).send(result.response); diff --git a/server/src/routes/medicine/comment/index.js b/server/src/routes/medicine/comment/index.js index 768c97e58..2b0537b00 100644 --- a/server/src/routes/medicine/comment/index.js +++ b/server/src/routes/medicine/comment/index.js @@ -9,9 +9,9 @@ router.post("/writeTest", verifyAccessToken, commentController.writeTest); //CRE router.post("/", commentController.get); //READ -> The function to get the medicine id, but the http body exists, so use post router.get("/:medicineId", commentController.getComment); //READ router.patch("/", verifyAccessToken, commentController.patch); //UPDATE -router.delete("/", verifyAccessToken, commentController.del); //DELETE +router.delete("/:medicineId/:medicineId/:commentId", verifyAccessToken, commentController.del); //DELETE // Like router.post("/:medicineId/like", verifyAccessToken, commentController.likePost); //CREATE -router.delete("/:medicineId/like", verifyAccessToken, commentController.likeDelete); //DELETE +router.delete("/:medicineId/like/:commentId", verifyAccessToken, commentController.likeDelete); //DELETE module.exports = router; \ No newline at end of file From 1b037746d5c31579684f14d8aa076b0bccbb7cd1 Mon Sep 17 00:00:00 2001 From: winocreative Date: Thu, 8 Jun 2023 01:57:18 +0900 Subject: [PATCH 58/70] =?UTF-8?q?Hotfix=20:=20=EC=95=88=EB=93=9C=EB=A1=9C?= =?UTF-8?q?=EC=9D=B4=EB=93=9C=20http=EC=9A=94=EC=B2=AD=EC=97=90=EC=84=9C?= =?UTF-8?q?=20Delete=EC=97=90=20body=EB=A5=BC=20=EB=AA=BB=EB=84=A3?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=8C=85=20=EC=88=98=EC=A0=95=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/comment/index.js | 3 +-- server/src/routes/medicine/comment/index.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/server/src/controller/comment/index.js b/server/src/controller/comment/index.js index 59be0acdf..3b6c37048 100644 --- a/server/src/controller/comment/index.js +++ b/server/src/controller/comment/index.js @@ -35,8 +35,7 @@ const del = async (req, res) => { return res.status(result.code).send(result.response); } const likePost = async (req, res) => { //addLike - const {medicineId} = req.params; - const {commentId} = req.body; + const {medicineId, commentId} = req.params; const {userId} = req.verifiedToken; const result = await addLike(userId, commentId); return res.status(result.code).send(result.response); diff --git a/server/src/routes/medicine/comment/index.js b/server/src/routes/medicine/comment/index.js index 2b0537b00..2e47bb389 100644 --- a/server/src/routes/medicine/comment/index.js +++ b/server/src/routes/medicine/comment/index.js @@ -12,6 +12,6 @@ router.patch("/", verifyAccessToken, commentController.patch); //UPDATE router.delete("/:medicineId/:medicineId/:commentId", verifyAccessToken, commentController.del); //DELETE // Like -router.post("/:medicineId/like", verifyAccessToken, commentController.likePost); //CREATE +router.post("/:medicineId/like/:commentId", verifyAccessToken, commentController.likePost); //CREATE router.delete("/:medicineId/like/:commentId", verifyAccessToken, commentController.likeDelete); //DELETE module.exports = router; \ No newline at end of file From 186c72faadfc5c9a0b9ea52cc4b424a696bc6525 Mon Sep 17 00:00:00 2001 From: winocreative Date: Thu, 8 Jun 2023 02:36:43 +0900 Subject: [PATCH 59/70] =?UTF-8?q?Hotfix=20:=20=5FgetLikeList=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=5FlikeList=20=EB=B3=80=EC=88=98=20=EC=84=A0?= =?UTF-8?q?=EC=96=B8=EC=97=90=20let=20=EB=B9=A0=EC=A7=84=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20fix=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service/commentService.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/service/commentService.js b/server/src/service/commentService.js index e4a919b80..1bc803eec 100644 --- a/server/src/service/commentService.js +++ b/server/src/service/commentService.js @@ -11,12 +11,13 @@ const _getLikeList = async (commentId) => { //NOT FOR EXPORT COMMENTID: commentId } }); - _likeList = []; + let _likeList = []; for (let i in likeList) { _likeList.push(likeList[i].dataValues); } return _likeList; } catch (err) { + console.log(err); return []; } } From 12d3beebe894793ebf7be047b98d4f95e502cb3d Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Thu, 10 Aug 2023 08:35:13 +0900 Subject: [PATCH 60/70] =?UTF-8?q?#203=20=ED=8C=8C=EC=9D=BC=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=9C=20multer=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/package-lock.json | 287 ++++++++++++++++++++++++++++++++++++ server/package.json | 1 + server/src/config/multer.js | 13 ++ 3 files changed, 301 insertions(+) create mode 100644 server/src/config/multer.js diff --git a/server/package-lock.json b/server/package-lock.json index f79730942..6c3cf885f 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -13,6 +13,7 @@ "dotenv": "^16.0.3", "express": "^4.18.2", "jsonwebtoken": "^9.0.0", + "multer": "^1.4.5-lts.1", "nodemon": "^2.0.22", "oracledb": "^5.5.0", "sequelize": "^6.31.0", @@ -156,6 +157,11 @@ "node": ">= 8" } }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -228,6 +234,22 @@ "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -320,6 +342,20 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -352,6 +388,11 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -794,6 +835,11 @@ "node": ">=0.12.0" } }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -955,6 +1001,14 @@ "node": "*" } }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -990,6 +1044,34 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/multer/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -1060,6 +1142,14 @@ "node": ">=0.10.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.12.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", @@ -1142,6 +1232,11 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -1195,6 +1290,25 @@ "node": ">= 0.8" } }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -1467,6 +1581,27 @@ "node": ">= 0.8" } }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -1602,6 +1737,11 @@ "node": ">= 0.6" } }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, "node_modules/undefsafe": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", @@ -1615,6 +1755,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", @@ -1677,6 +1822,14 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -1865,6 +2018,11 @@ "picomatch": "^2.0.4" } }, + "append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" + }, "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -1927,6 +2085,19 @@ "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "requires": { + "streamsearch": "^1.1.0" + } + }, "bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -1996,6 +2167,17 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -2019,6 +2201,11 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -2355,6 +2542,11 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" + }, "js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -2481,6 +2673,11 @@ "brace-expansion": "^1.1.7" } }, + "minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" + }, "mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -2504,6 +2701,30 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "requires": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "requires": { + "minimist": "^1.2.6" + } + } + } + }, "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -2554,6 +2775,11 @@ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" }, + "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==" + }, "object-inspect": { "version": "1.12.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", @@ -2614,6 +2840,11 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -2652,6 +2883,27 @@ "unpipe": "1.0.0" } }, + "readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, "readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -2825,6 +3077,26 @@ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" }, + "streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -2924,6 +3196,11 @@ "mime-types": "~2.1.24" } }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" + }, "undefsafe": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", @@ -2934,6 +3211,11 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==" }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -2978,6 +3260,11 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/server/package.json b/server/package.json index 0aa5c8feb..75407ae0a 100644 --- a/server/package.json +++ b/server/package.json @@ -18,6 +18,7 @@ "dotenv": "^16.0.3", "express": "^4.18.2", "jsonwebtoken": "^9.0.0", + "multer": "^1.4.5-lts.1", "nodemon": "^2.0.22", "oracledb": "^5.5.0", "sequelize": "^6.31.0", diff --git a/server/src/config/multer.js b/server/src/config/multer.js new file mode 100644 index 000000000..5742cb31b --- /dev/null +++ b/server/src/config/multer.js @@ -0,0 +1,13 @@ +const multer = require("multer"); +const { nanoid } = require("nanoid"); + +const storage = multer.diskStorage({ + destination: (req, file, cb) => { + cb(null, "./imgs"); // destination to store file + }, + filename: (req, file, cb) => { + cb(null, Date.now() + nanoid()); // 'Current time + random string' + }, +}); + +exports.upload = multer({ storage: storage }); \ No newline at end of file From df0bf8ac1730c61c17d1bd13aefa67ce0f972e81 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Thu, 10 Aug 2023 08:43:54 +0900 Subject: [PATCH 61/70] =?UTF-8?q?#203=20express=20=EC=8B=A4=ED=96=89=20?= =?UTF-8?q?=EC=8B=9C=20=ED=8C=8C=EC=9D=BC=20=EC=97=85=EB=A1=9C=EB=93=9C=20?= =?UTF-8?q?=EB=94=94=EB=A0=89=ED=86=A0=EB=A6=AC=20=EC=B2=B4=ED=81=AC=20?= =?UTF-8?q?=ED=9B=84=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/www.js | 80 +++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/server/bin/www.js b/server/bin/www.js index 673b1662c..06411e64c 100644 --- a/server/bin/www.js +++ b/server/bin/www.js @@ -1,40 +1,58 @@ "use strict"; const app = require("../app"); -const models = require('../src/models/index.js'); +const models = require("../src/models/index.js"); const PORT = process.env.PORT || 3000; // 포트 -const { auto } = require("../src/config/sequelizeAuto") +const { auto } = require("../src/config/sequelizeAuto"); -const oracledb = require("oracledb") +const oracledb = require("oracledb"); +const dir = "./imgs"; // path to save uploaded files app.listen(PORT, async () => { - if (process.env.NODE_ENV == 'development') { // 현재 개발 환경이라면 - oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // 개발 머신에 따라 oracle client 경로 수동 설정 - } - - try { - await models.sequelize.sync({force: false, alter: false}); - } catch (err) { - console.log('DB 연결 중 오류 발생: ', err); - process.exit(); - } - - // Find all users - const users = await models.User.findAll(); - console.log(users.every(user => user instanceof models.User)); // true - console.log("All users:", JSON.stringify(users, null, 2)); - console.log("All medicines:", JSON.stringify(await models.Medicine.findAll(), null, 2)); - console.log("All likes:", JSON.stringify(await models.Like.findAll(), null, 2)); - console.log("All comments:", JSON.stringify(await models.Comment.findAll(), null, 2)); - console.log("All favorite medicines:", JSON.stringify(await models.FavoriteMedicine.findAll(), null, 2)); - - // // model auto generation test - // auto.run((err) => { - // if (err) throw err; - // console.log(auto.tables); // 생성된 모델 확인 - // }); - - console.log(`Server running on port ${PORT}`); -}); \ No newline at end of file + if (process.env.NODE_ENV == "development") { + // 현재 개발 환경이라면 + oracledb.initOracleClient({ libDir: process.env.DB_ORACLEHOME }); // 개발 머신에 따라 oracle client 경로 수동 설정 + } + + try { + await models.sequelize.sync({ force: false, alter: false }); + } catch (err) { + console.log("DB 연결 중 오류 발생: ", err); + process.exit(); + } + + // Find all users + const users = await models.User.findAll(); + console.log(users.every((user) => user instanceof models.User)); // true + console.log("All users:", JSON.stringify(users, null, 2)); + console.log( + "All medicines:", + JSON.stringify(await models.Medicine.findAll(), null, 2) + ); + console.log( + "All likes:", + JSON.stringify(await models.Like.findAll(), null, 2) + ); + console.log( + "All comments:", + JSON.stringify(await models.Comment.findAll(), null, 2) + ); + console.log( + "All favorite medicines:", + JSON.stringify(await models.FavoriteMedicine.findAll(), null, 2) + ); + + // // model auto generation test + // auto.run((err) => { + // if (err) throw err; + // console.log(auto.tables); // 생성된 모델 확인 + // }); + + if (!fs.existsSync(dir)) { // path doesn't exist + fs.mkdirSync(dir); // create directory + } + + console.log(`Server running on port ${PORT}`); +}); From 3f1e13ed5be10f52a6850c83431e80e23c7d98a1 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Thu, 10 Aug 2023 08:45:19 +0900 Subject: [PATCH 62/70] =?UTF-8?q?#203=20USER=20=EB=AA=A8=EB=8D=B8=EC=97=90?= =?UTF-8?q?=20=ED=94=84=EB=A1=9C=ED=95=84=20=EC=82=AC=EC=A7=84=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/models/user.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/models/user.js b/server/src/models/user.js index d0093e198..a79019af1 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -25,6 +25,12 @@ module.exports = function (sequelize, DataTypes) { type: DataTypes.STRING, allowNull: false, unique: true + }, + PROFILE_URL: { + field: 'PROFILE_URL', + type: DataTypes.STRING, + allowNull: false, + defaultValue: 'default' } }, { underscored: true, From a792cca54253f738f6b8076320269a38ced81c0f Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Thu, 10 Aug 2023 09:26:44 +0900 Subject: [PATCH 63/70] =?UTF-8?q?#203=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20static=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EB=AA=A8=EB=93=88=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/staticDirLoc.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 server/src/config/staticDirLoc.js diff --git a/server/src/config/staticDirLoc.js b/server/src/config/staticDirLoc.js new file mode 100644 index 000000000..00ec84c65 --- /dev/null +++ b/server/src/config/staticDirLoc.js @@ -0,0 +1,6 @@ +const path = require('path'); +const imgsDir = path.join(__dirname, '..', 'imgs'); // path to save uploaded files + +module.exports = { + imgsDir +}; \ No newline at end of file From 7741d595d396d902ac1e60c3e43e756caccc5824 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Thu, 10 Aug 2023 09:27:37 +0900 Subject: [PATCH 64/70] =?UTF-8?q?#203=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=ED=8F=B4=EB=8D=94=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EB=AA=A8=EB=93=88=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/bin/www.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/bin/www.js b/server/bin/www.js index 06411e64c..a04e93223 100644 --- a/server/bin/www.js +++ b/server/bin/www.js @@ -3,13 +3,13 @@ const app = require("../app"); const models = require("../src/models/index.js"); const PORT = process.env.PORT || 3000; // 포트 +const fs = require("fs"); +const { imgsDir } = require("../src/config/staticDirLoc"); const { auto } = require("../src/config/sequelizeAuto"); const oracledb = require("oracledb"); -const dir = "./imgs"; // path to save uploaded files - app.listen(PORT, async () => { if (process.env.NODE_ENV == "development") { // 현재 개발 환경이라면 @@ -50,8 +50,13 @@ app.listen(PORT, async () => { // console.log(auto.tables); // 생성된 모델 확인 // }); - if (!fs.existsSync(dir)) { // path doesn't exist - fs.mkdirSync(dir); // create directory + if (!fs.existsSync(imgsDir)) { // path doesn't exist + try { + fs.mkdirSync(imgsDir); // create directory + console.log("Directory created successfully."); + } catch (error) { + console.error("Error creating directory:", error); + } } console.log(`Server running on port ${PORT}`); From 970fb088430bcd2647eb06b8a1e16b2ecfd4e026 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Thu, 10 Aug 2023 09:50:32 +0900 Subject: [PATCH 65/70] =?UTF-8?q?#203=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20static=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EB=AA=A8=EB=93=88=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/app.js b/server/app.js index 707af7c79..3a00f0721 100644 --- a/server/app.js +++ b/server/app.js @@ -7,6 +7,8 @@ const bodyParser = require('body-parser'); const dotenv = require("dotenv"); dotenv.config(); const { swaggerUi, specs } = require("./swagger/swagger"); // swagger +const path = require("path"); +const imgsDir = path.join(__dirname, '..', 'imgs'); // path to save uploaded files // 라우팅 const home = require("./src/routes/home"); @@ -16,6 +18,9 @@ const home = require("./src/routes/home"); app.use(express.json()) // 내장 body-parser app.use(express.urlencoded({ extended: true })) +// set static folder +app.use('/imgs', express.static(imgsDir)); // folder destination + app.use("/", home); app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs)) From 7488fd804bf0940b755fa1d933026cd2a3013e62 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Thu, 10 Aug 2023 09:51:06 +0900 Subject: [PATCH 66/70] =?UTF-8?q?#203=20multer=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=ED=8F=B4=EB=8D=94=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EB=AA=A8=EB=93=88=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/config/multer.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/config/multer.js b/server/src/config/multer.js index 5742cb31b..3b019cecf 100644 --- a/server/src/config/multer.js +++ b/server/src/config/multer.js @@ -1,13 +1,15 @@ const multer = require("multer"); +const path = require("path"); const { nanoid } = require("nanoid"); +const { imgsDir } = require("../src/config/staticDirLoc"); const storage = multer.diskStorage({ destination: (req, file, cb) => { - cb(null, "./imgs"); // destination to store file + cb(null, imgsDir); // destination to store file }, filename: (req, file, cb) => { - cb(null, Date.now() + nanoid()); // 'Current time + random string' + cb(null, Date.now() + nanoid() + path.extname(file.originalname)); // 'Current time + random string + file extension' }, }); -exports.upload = multer({ storage: storage }); \ No newline at end of file +exports.upload = multer({ storage: storage }); From 872c911e3e0aeb27733d9e5eb1798cc82e17cd2f Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:09:10 +0900 Subject: [PATCH 67/70] =?UTF-8?q?#203=20=EC=9C=A0=EC=A0=80=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=B0=98=ED=99=98,=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=88=98=EC=A0=95=20API=EC=97=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=82=AC=EC=A7=84=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=ED=8F=AC=ED=95=A8=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/user/user.ctrl.js | 11 +- server/src/models/user.js | 2 +- server/src/routes/user/userRouter.js | 4 +- server/src/service/userService.js | 197 ++++++++++++++++-------- 4 files changed, 149 insertions(+), 65 deletions(-) diff --git a/server/src/controller/user/user.ctrl.js b/server/src/controller/user/user.ctrl.js index f1d9936fc..b79e19cc4 100644 --- a/server/src/controller/user/user.ctrl.js +++ b/server/src/controller/user/user.ctrl.js @@ -60,8 +60,15 @@ const edit = { // [PATCH] /user patchUserInfo: async (req, res) => { const { userId } = req.verifiedToken; - const { newNickname, newPassword } = req.body; - const result = await updateUserInfo(userId, newNickname, newPassword); // update user nickname or password + const { newNickname, newPassword } = req.body; + let profile_img = req.file; + + if (profile_img) { // image exists + profile_img = profile_img.filename; // name of the uploaded image + } else { // if profile_img is null, change to default image + profile_img = "default.jpg"; + } + const result = await updateUserInfo(userId, newNickname, newPassword, profile_img); // update user information return res.status(result.code).send(result.response); } } diff --git a/server/src/models/user.js b/server/src/models/user.js index a79019af1..a227bb9fd 100644 --- a/server/src/models/user.js +++ b/server/src/models/user.js @@ -30,7 +30,7 @@ module.exports = function (sequelize, DataTypes) { field: 'PROFILE_URL', type: DataTypes.STRING, allowNull: false, - defaultValue: 'default' + defaultValue: 'default.jpg' } }, { underscored: true, diff --git a/server/src/routes/user/userRouter.js b/server/src/routes/user/userRouter.js index d1418015d..916af76c5 100644 --- a/server/src/routes/user/userRouter.js +++ b/server/src/routes/user/userRouter.js @@ -3,6 +3,8 @@ const userCtrl = require('../../controller/user/user.ctrl'); const { verifyRefreshToken, verifyAccessToken } = require("../../config/jwt"); const router = require("express").Router(); +const { upload } = require("../../config/multer"); + /** * @swagger * /user/login: @@ -154,7 +156,7 @@ router.post("/reissue", verifyRefreshToken, userCtrl.process.reissue); // reissu */ router.post("/register", userCtrl.process.register); // sign-up router.get("/", verifyAccessToken, userCtrl.output.getUserInfo) // get user information -router.patch("/", verifyAccessToken, userCtrl.edit.patchUserInfo) // edit user information +router.patch("/", verifyAccessToken, upload.single('profile_img'), userCtrl.edit.patchUserInfo) // edit user information router.delete("/", verifyAccessToken, userCtrl.eliminate.deleteUser) // delete user router.get("/comment", verifyAccessToken, userCtrl.output.getCommentListFromUserId); module.exports = router; \ No newline at end of file diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 58b105156..6e6f5dd0c 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -4,152 +4,228 @@ const { User } = require("../models/index"); const { responseFormat } = require("../config/response"); const responseMsg = require("../config/responseMsg"); const { createAccessToken, createRefreshToken } = require("../config/jwt"); +const { imgsDir } = require("../src/config/staticDirLoc"); // sign-in response format -const tokenResponseFormat = (message, userId = null, nickname = null, email = null, access_token = null, refresh_token = null) => { - let struct = {}; - struct.message = message; +const tokenResponseFormat = ( + message, + userId = null, + nickname = null, + email = null, + access_token = null, + refresh_token = null +) => { + let struct = {}; + struct.message = message; if (userId) struct.userId = userId; if (nickname) struct.nickname = nickname; if (email) struct.email = email; if (access_token) struct.access_token = access_token; if (refresh_token) struct.refresh_token = refresh_token; return struct; -} -const _getUserNickname = async (userId) => { //NOT FOR EXPORT +}; +const _getUserNickname = async (userId) => { + //NOT FOR EXPORT try { const user = await User.findOne({ attributes: ["NICKNAME"], where: { - ID: userId - } + ID: userId, + }, }); return user.NICKNAME; } catch (err) { return null; } -} +}; // sign-in const login = async (email, password) => { const user = await User.findOne({ attributes: ["ID", "PASSWORD", "NICKNAME", "EMAIL"], where: { - EMAIL: email - } + EMAIL: email, + }, }); - if (!user) { // if user not exists - return responseFormat(404, tokenResponseFormat(responseMsg.SIGNIN_USER_NOT_FOUND)); + if (!user) { + // if user not exists + return responseFormat( + 404, + tokenResponseFormat(responseMsg.SIGNIN_USER_NOT_FOUND) + ); } - if (password != user.PASSWORD) { // password mismatch - return responseFormat(401, tokenResponseFormat(responseMsg.SIGNIN_PASSWORD_MISMATCH)); + if (password != user.PASSWORD) { + // password mismatch + return responseFormat( + 401, + tokenResponseFormat(responseMsg.SIGNIN_PASSWORD_MISMATCH) + ); } const message = responseMsg.SIGNIN_SUCCESS; // generate response message const accessToken = createAccessToken(user.ID); // generate access token const refreshToken = createRefreshToken(user.ID); // generate refresh token - return responseFormat(200, tokenResponseFormat(message, user.ID, user.NICKNAME, user.EMAIL, accessToken, refreshToken)); -} + return responseFormat( + 200, + tokenResponseFormat( + message, + user.ID, + user.NICKNAME, + user.EMAIL, + accessToken, + refreshToken + ) + ); +}; // duplicate check const duplicateCheck = async (parameter) => { - if (await User.findOne({ // if user exists - where: parameter - })) { + if ( + await User.findOne({ + // if user exists + where: parameter, + }) + ) { return true; } return false; // if user not exists -} +}; + +// get user profile image url +const getUserProfileURL = async (profile_url) => { + return `${imgsDir}/${profile_url}`; +}; // get user info const getUserInfo = async (user_id) => { try { // get user - const user = (await User.findOne({ - attributes: ["ID", "EMAIL", "NICKNAME"], - where: { ID: user_id } - })).dataValues; + const user = ( + await User.findOne({ + attributes: ["ID", "EMAIL", "NICKNAME", "PROFILE_URL"], + where: { ID: user_id }, + }) + ).dataValues; + + const profile_url = getUserProfileURL(user.PROFILE_URL); + return responseFormat(200, { userId: user.ID, email: user.EMAIL, nickname: user.NICKNAME, + profile_url, message: responseMsg.USER_GET_COMPLETE, }); // get user SUCCESS - } - catch (err) { + } catch (err) { console.log(err); return responseFormat(500, { message: responseMsg.USER_GET_FAIL }); } -} +}; // create user const createUser = async (email, password, nickname) => { // duplicate check - let checkParam = "EMAIL" - if (await duplicateCheck({ [checkParam]: email })) { // email - return responseFormat(409, tokenResponseFormat(responseMsg.DUPLICATE_PARAMETER(checkParam))); + let checkParam = "EMAIL"; + if (await duplicateCheck({ [checkParam]: email })) { + // email + return responseFormat( + 409, + tokenResponseFormat(responseMsg.DUPLICATE_PARAMETER(checkParam)) + ); } checkParam = "NICKNAME"; - if (await duplicateCheck({ [checkParam]: nickname })) { // nickname - return responseFormat(409, tokenResponseFormat(responseMsg.DUPLICATE_PARAMETER(checkParam))); + if (await duplicateCheck({ [checkParam]: nickname })) { + // nickname + return responseFormat( + 409, + tokenResponseFormat(responseMsg.DUPLICATE_PARAMETER(checkParam)) + ); } try { - const user = await User.create({ // insert new User into DB + const user = await User.create({ + // insert new User into DB EMAIL: email, PASSWORD: password, - NICKNAME: nickname + NICKNAME: nickname, }); const message = responseMsg.SIGNUP_SUCCESS; // generate response message const accessToken = createAccessToken(user.ID); // generate access token const refreshToken = createRefreshToken(user.ID); // generate refresh token - return responseFormat(201, tokenResponseFormat(message, user.ID, user.NICKNAME, user.EMAIL, accessToken, refreshToken)); - - } - catch (err) { + return responseFormat( + 201, + tokenResponseFormat( + message, + user.ID, + user.NICKNAME, + user.EMAIL, + accessToken, + refreshToken + ) + ); + } catch (err) { console.log(err); - return responseFormat(500, tokenResponseFormat(responseMsg.SIGNUP_INTERNAL_SERVER_ERROR)); + return responseFormat( + 500, + tokenResponseFormat(responseMsg.SIGNUP_INTERNAL_SERVER_ERROR) + ); } -} +}; // reissue token const reissueToken = (userId) => { const message = responseMsg.REISSUE_SUCCESS; const accessToken = createAccessToken(userId); // generate access token const refreshToken = createRefreshToken(userId); // generate refresh token - return responseFormat(200, tokenResponseFormat(message, null, null, null, accessToken, refreshToken)); -} + return responseFormat( + 200, + tokenResponseFormat( + message, + null, + null, + null, + accessToken, + refreshToken + ) + ); +}; // update user information -const updateUserInfo = async (user_id, new_nickname, new_password) => { +const updateUserInfo = async (user_id, new_nickname, new_password, profile_img) => { let updateCondition, checkParam; - if (new_nickname && !new_password) { // update user nickname + if (new_nickname && !new_password && !profile_img) { // update user nickname checkParam = "NICKNAME"; updateCondition = { [checkParam]: new_nickname }; // nickname duplicate check if (await duplicateCheck(updateCondition)) { - return responseFormat(409, responseMsg.DUPLICATE_PARAMETER(checkParam)); + return responseFormat( + 409, + responseMsg.DUPLICATE_PARAMETER(checkParam) + ); } - } else if (!new_nickname && new_password) { // update user password + } else if (!new_nickname && new_password && !profile_img) { // update user password checkParam = "PASSWORD"; updateCondition = { [checkParam]: new_password }; + } else if(!new_nickname && !new_password && profile_img) { // update user profile image + checkParam = "PROFILE_URL"; + updateCondition = { [checkParam]: profile_img }; } try { // update user information - await User.update( - updateCondition, - { where: { ID: user_id } } - ); - return responseFormat(200, { message: responseMsg.USER_UPDATE_COMPLETE(checkParam) }); - } - catch (err) { + await User.update(updateCondition, { where: { ID: user_id } }); + return responseFormat(200, { + message: responseMsg.USER_UPDATE_COMPLETE(checkParam), + }); + } catch (err) { console.log(err); - return responseFormat(500, { message: responseMsg.USER_UPDATE_FAIL(checkParam) }); + return responseFormat(500, { + message: responseMsg.USER_UPDATE_FAIL(checkParam), + }); } -} +}; // delete user const deleteUser = async (user_id) => { @@ -158,19 +234,18 @@ const deleteUser = async (user_id) => { const updated = await User.update( { EMAIL: `destroyed_${user_id}`, - NICKNAME: `알수없음_${user_id}` + NICKNAME: `알수없음_${user_id}`, }, { where: { ID: user_id } } ); return responseFormat(200, { message: responseMsg.USER_DELETE_COMPLETE, }); // delete SUCCESS - } - catch (err) { + } catch (err) { console.log(err); return responseFormat(500, { message: responseMsg.USER_DELETE_FAIL }); } -} +}; module.exports = { _getUserNickname, @@ -179,5 +254,5 @@ module.exports = { reissueToken, updateUserInfo, deleteUser, - getUserInfo -} \ No newline at end of file + getUserInfo, +}; From b0b84b3543ca22d37b6ad219d7e9930b1a660605 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Tue, 22 Aug 2023 20:19:52 +0900 Subject: [PATCH 68/70] =?UTF-8?q?#203=20nanoid=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=EB=B2=84=EC=A0=84=20=EC=B6=A9=EB=8F=8C=EB=A1=9C=20=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20=EB=B2=84=EC=A0=84=20=EB=8B=A4=EC=9A=B4=EA=B7=B8?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/package-lock.json | 23 +++++++++++++++++++++++ server/package.json | 1 + server/src/config/multer.js | 2 +- server/src/service/userService.js | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/server/package-lock.json b/server/package-lock.json index 6c3cf885f..7e5833fa7 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -14,6 +14,7 @@ "express": "^4.18.2", "jsonwebtoken": "^9.0.0", "multer": "^1.4.5-lts.1", + "nanoid": "^3.3.6", "nodemon": "^2.0.22", "oracledb": "^5.5.0", "sequelize": "^6.31.0", @@ -1072,6 +1073,23 @@ "mkdirp": "bin/cmd.js" } }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -2725,6 +2743,11 @@ } } }, + "nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==" + }, "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", diff --git a/server/package.json b/server/package.json index 75407ae0a..17d5281ec 100644 --- a/server/package.json +++ b/server/package.json @@ -19,6 +19,7 @@ "express": "^4.18.2", "jsonwebtoken": "^9.0.0", "multer": "^1.4.5-lts.1", + "nanoid": "^3.3.6", "nodemon": "^2.0.22", "oracledb": "^5.5.0", "sequelize": "^6.31.0", diff --git a/server/src/config/multer.js b/server/src/config/multer.js index 3b019cecf..b546e6c7a 100644 --- a/server/src/config/multer.js +++ b/server/src/config/multer.js @@ -1,7 +1,7 @@ const multer = require("multer"); const path = require("path"); const { nanoid } = require("nanoid"); -const { imgsDir } = require("../src/config/staticDirLoc"); +const { imgsDir } = require("../config/staticDirLoc"); const storage = multer.diskStorage({ destination: (req, file, cb) => { diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 6e6f5dd0c..7b6d1df43 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -4,7 +4,7 @@ const { User } = require("../models/index"); const { responseFormat } = require("../config/response"); const responseMsg = require("../config/responseMsg"); const { createAccessToken, createRefreshToken } = require("../config/jwt"); -const { imgsDir } = require("../src/config/staticDirLoc"); +const { imgsDir } = require("../config/staticDirLoc"); // sign-in response format const tokenResponseFormat = ( From 5aacc1284e5fc6962aa11a9d0d1b2b3de3a26bf5 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Tue, 22 Aug 2023 20:26:40 +0900 Subject: [PATCH 69/70] =?UTF-8?q?#203=20gitignore=EC=97=90=20static=20fold?= =?UTF-8?q?er=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 17db6df71..8ddacfa54 100644 --- a/.gitignore +++ b/.gitignore @@ -81,4 +81,7 @@ lint/intermediates/ lint/generated/ lint/outputs/ lint/tmp/ -# lint/reports/ \ No newline at end of file +# lint/reports/ + +# Static folder +imgs/ \ No newline at end of file From 2fef3b83edcf27b3f6e4e6983b4f69f7d147b532 Mon Sep 17 00:00:00 2001 From: ho-sick99 <83945722+JunoJuno99@users.noreply.github.com> Date: Tue, 22 Aug 2023 20:48:25 +0900 Subject: [PATCH 70/70] =?UTF-8?q?#203=20static=20folder=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app.js | 14 +++++++------- server/src/config/staticDirLoc.js | 2 +- server/src/service/userService.js | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/app.js b/server/app.js index 3a00f0721..2d2fe22a3 100644 --- a/server/app.js +++ b/server/app.js @@ -3,26 +3,26 @@ // 모듈 const express = require("express"); const app = express(); -const bodyParser = require('body-parser'); +const bodyParser = require("body-parser"); const dotenv = require("dotenv"); dotenv.config(); const { swaggerUi, specs } = require("./swagger/swagger"); // swagger const path = require("path"); -const imgsDir = path.join(__dirname, '..', 'imgs'); // path to save uploaded files +const { imgsDir } = require("./src/config/staticDirLoc"); // path to save uploaded files // 라우팅 const home = require("./src/routes/home"); // 미들웨어 // app.use(bodyParser.json()); -app.use(express.json()) // 내장 body-parser -app.use(express.urlencoded({ extended: true })) +app.use(express.json()); // 내장 body-parser +app.use(express.urlencoded({ extended: true })); // set static folder -app.use('/imgs', express.static(imgsDir)); // folder destination +app.use("/imgs", express.static(imgsDir)); // folder destination app.use("/", home); -app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs)) +app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs)); -module.exports = app; \ No newline at end of file +module.exports = app; diff --git a/server/src/config/staticDirLoc.js b/server/src/config/staticDirLoc.js index 00ec84c65..5b06ee565 100644 --- a/server/src/config/staticDirLoc.js +++ b/server/src/config/staticDirLoc.js @@ -1,5 +1,5 @@ const path = require('path'); -const imgsDir = path.join(__dirname, '..', 'imgs'); // path to save uploaded files +const imgsDir = path.join('imgs'); // path to save uploaded files module.exports = { imgsDir diff --git a/server/src/service/userService.js b/server/src/service/userService.js index 7b6d1df43..ce758cf78 100644 --- a/server/src/service/userService.js +++ b/server/src/service/userService.js @@ -106,9 +106,9 @@ const getUserInfo = async (user_id) => { where: { ID: user_id }, }) ).dataValues; - - const profile_url = getUserProfileURL(user.PROFILE_URL); - + + const profile_url = await getUserProfileURL(user.PROFILE_URL); + return responseFormat(200, { userId: user.ID, email: user.EMAIL,