├── .env.sample ├── .gitignore ├── .prettierignore ├── .prettierrc ├── package-lock.json ├── package.json ├── public └── temp │ └── .gitkeep ├── readme.md ├── src ├── app.js ├── constants.js ├── controllers │ ├── comment.controller.js │ ├── dashboard.controller.js │ ├── healthcheck.controller.js │ ├── like.controller.js │ ├── playlist.controller.js │ ├── subscription.controller.js │ ├── tweet.controller.js │ ├── user.controller.js │ └── video.controller.js ├── db │ └── dbConnect.js ├── index.js ├── middlewares │ ├── auth.middleware.js │ └── multer.middleware.js ├── models │ ├── comment.model.js │ ├── like.model.js │ ├── playlist.model.js │ ├── subscription.model.js │ ├── tweet.model.js │ ├── user.model.js │ └── video.model.js ├── routes │ ├── comment.routes.js │ ├── dashboard.routes.js │ ├── healthcheck.routes.js │ ├── like.routes.js │ ├── playlist.routes.js │ ├── subscription.routes.js │ ├── tweet.routes.js │ ├── user.routes.js │ └── video.routes.js └── utils │ ├── ApiResponse.js │ ├── apiError.js │ ├── asyncHandler.js │ └── cloudinary.js └── vercel.json /.env.sample: -------------------------------------------------------------------------------- 1 | PORT=3000 2 | MONGODB_URL=mongodb+srv://your_username:your_password@your_cluster_url 3 | CORS_ORIGIN=* 4 | ACCESS_TOKEN_SECRET=your_access_token_secret 5 | ACCESS_TOKEN_EXPIRY=1d 6 | REFRESH_TOKEN_SECRET=your_refresh_token_secret 7 | REFRESH_TOKEN_EXPIRY=10d 8 | 9 | CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name 10 | CLOUDINARY_API_KEY=your_cloudinary_api_key 11 | CLOUDINARY_API_SECRET=your_cloudinary_api_secret -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Microbundle cache 58 | .rpt2_cache/ 59 | .rts2_cache_cjs/ 60 | .rts2_cache_es/ 61 | .rts2_cache_umd/ 62 | 63 | # Optional REPL history 64 | .node_repl_history 65 | 66 | # Output of 'npm pack' 67 | *.tgz 68 | 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | 72 | # dotenv environment variables file 73 | .env 74 | .env.test 75 | .env.production 76 | 77 | # parcel-bundler cache (https://parceljs.org/) 78 | .cache 79 | .parcel-cache 80 | 81 | # Next.js build output 82 | .next 83 | out 84 | 85 | # Nuxt.js build / generate output 86 | .nuxt 87 | dist 88 | 89 | # Gatsby files 90 | .cache/ 91 | # Comment in the public line in if your project uses Gatsby and not Next.js 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # public 94 | 95 | # vuepress build output 96 | .vuepress/dist 97 | 98 | # Serverless directories 99 | .serverless/ 100 | 101 | # FuseBox cache 102 | .fusebox/ 103 | 104 | # DynamoDB Local files 105 | .dynamodb/ 106 | 107 | # TernJS port file 108 | .tern-port 109 | 110 | # Stores VSCode versions used for testing VSCode extensions 111 | .vscode-test 112 | 113 | # yarn v2 114 | .yarn/cache 115 | .yarn/unplugged 116 | .yarn/build-state.yml 117 | .yarn/install-state.gz 118 | .pnp.* 119 | 120 | # End of https://mrkandreev.name/snippets/gitignore-generator/#Node -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | /.vscode 2 | /node_modules 3 | ./dist 4 | 5 | *.env 6 | .env 7 | .env.* -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": false, 3 | "bracketSpacing": true, 4 | "tabWidth": 4, 5 | "trailingComma": "none", 6 | "semi": true 7 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coffee-backend", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "coffee-backend", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "bcrypt": "^5.1.1", 13 | "cloudinary": "^1.41.0", 14 | "cookie-parser": "^1.4.6", 15 | "cors": "^2.8.5", 16 | "dotenv": "^16.3.1", 17 | "express": "^4.18.2", 18 | "jsonwebtoken": "^9.0.2", 19 | "mongoose": "^8.0.0", 20 | "mongoose-aggregate-paginate-v2": "^1.0.6", 21 | "morgan": "^1.10.0", 22 | "multer": "^1.4.5-lts.1" 23 | }, 24 | "devDependencies": { 25 | "nodemon": "^3.0.1", 26 | "prettier": "^3.0.3" 27 | } 28 | }, 29 | "node_modules/@mapbox/node-pre-gyp": { 30 | "version": "1.0.11", 31 | "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", 32 | "integrity": "sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==", 33 | "dependencies": { 34 | "detect-libc": "^2.0.0", 35 | "https-proxy-agent": "^5.0.0", 36 | "make-dir": "^3.1.0", 37 | "node-fetch": "^2.6.7", 38 | "nopt": "^5.0.0", 39 | "npmlog": "^5.0.1", 40 | "rimraf": "^3.0.2", 41 | "semver": "^7.3.5", 42 | "tar": "^6.1.11" 43 | }, 44 | "bin": { 45 | "node-pre-gyp": "bin/node-pre-gyp" 46 | } 47 | }, 48 | "node_modules/@mapbox/node-pre-gyp/node_modules/nopt": { 49 | "version": "5.0.0", 50 | "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", 51 | "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", 52 | "dependencies": { 53 | "abbrev": "1" 54 | }, 55 | "bin": { 56 | "nopt": "bin/nopt.js" 57 | }, 58 | "engines": { 59 | "node": ">=6" 60 | } 61 | }, 62 | "node_modules/@mongodb-js/saslprep": { 63 | "version": "1.1.1", 64 | "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz", 65 | "integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==", 66 | "dependencies": { 67 | "sparse-bitfield": "^3.0.3" 68 | } 69 | }, 70 | "node_modules/@types/node": { 71 | "version": "20.8.10", 72 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.10.tgz", 73 | "integrity": "sha512-TlgT8JntpcbmKUFzjhsyhGfP2fsiz1Mv56im6enJ905xG1DAYesxJaeSbGqQmAw8OWPdhyJGhGSQGKRNJ45u9w==", 74 | "dependencies": { 75 | "undici-types": "~5.26.4" 76 | } 77 | }, 78 | "node_modules/@types/webidl-conversions": { 79 | "version": "7.0.2", 80 | "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.2.tgz", 81 | "integrity": "sha512-uNv6b/uGRLlCVmelat2rA8bcVd3k/42mV2EmjhPh6JLkd35T5bgwR/t6xy7a9MWhd9sixIeBUzhBenvk3NO+DQ==" 82 | }, 83 | "node_modules/@types/whatwg-url": { 84 | "version": "8.2.2", 85 | "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.2.tgz", 86 | "integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==", 87 | "dependencies": { 88 | "@types/node": "*", 89 | "@types/webidl-conversions": "*" 90 | } 91 | }, 92 | "node_modules/abbrev": { 93 | "version": "1.1.1", 94 | "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", 95 | "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" 96 | }, 97 | "node_modules/accepts": { 98 | "version": "1.3.8", 99 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", 100 | "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", 101 | "dependencies": { 102 | "mime-types": "~2.1.34", 103 | "negotiator": "0.6.3" 104 | }, 105 | "engines": { 106 | "node": ">= 0.6" 107 | } 108 | }, 109 | "node_modules/agent-base": { 110 | "version": "6.0.2", 111 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", 112 | "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", 113 | "dependencies": { 114 | "debug": "4" 115 | }, 116 | "engines": { 117 | "node": ">= 6.0.0" 118 | } 119 | }, 120 | "node_modules/agent-base/node_modules/debug": { 121 | "version": "4.3.4", 122 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 123 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 124 | "dependencies": { 125 | "ms": "2.1.2" 126 | }, 127 | "engines": { 128 | "node": ">=6.0" 129 | }, 130 | "peerDependenciesMeta": { 131 | "supports-color": { 132 | "optional": true 133 | } 134 | } 135 | }, 136 | "node_modules/agent-base/node_modules/ms": { 137 | "version": "2.1.2", 138 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 139 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 140 | }, 141 | "node_modules/ansi-regex": { 142 | "version": "5.0.1", 143 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", 144 | "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", 145 | "engines": { 146 | "node": ">=8" 147 | } 148 | }, 149 | "node_modules/anymatch": { 150 | "version": "3.1.3", 151 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", 152 | "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", 153 | "dev": true, 154 | "dependencies": { 155 | "normalize-path": "^3.0.0", 156 | "picomatch": "^2.0.4" 157 | }, 158 | "engines": { 159 | "node": ">= 8" 160 | } 161 | }, 162 | "node_modules/append-field": { 163 | "version": "1.0.0", 164 | "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", 165 | "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==" 166 | }, 167 | "node_modules/aproba": { 168 | "version": "2.0.0", 169 | "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", 170 | "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" 171 | }, 172 | "node_modules/are-we-there-yet": { 173 | "version": "2.0.0", 174 | "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", 175 | "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", 176 | "dependencies": { 177 | "delegates": "^1.0.0", 178 | "readable-stream": "^3.6.0" 179 | }, 180 | "engines": { 181 | "node": ">=10" 182 | } 183 | }, 184 | "node_modules/array-flatten": { 185 | "version": "1.1.1", 186 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 187 | "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" 188 | }, 189 | "node_modules/balanced-match": { 190 | "version": "1.0.2", 191 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 192 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" 193 | }, 194 | "node_modules/basic-auth": { 195 | "version": "2.0.1", 196 | "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", 197 | "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", 198 | "dependencies": { 199 | "safe-buffer": "5.1.2" 200 | }, 201 | "engines": { 202 | "node": ">= 0.8" 203 | } 204 | }, 205 | "node_modules/basic-auth/node_modules/safe-buffer": { 206 | "version": "5.1.2", 207 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 208 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 209 | }, 210 | "node_modules/bcrypt": { 211 | "version": "5.1.1", 212 | "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz", 213 | "integrity": "sha512-AGBHOG5hPYZ5Xl9KXzU5iKq9516yEmvCKDg3ecP5kX2aB6UqTeXZxk2ELnDgDm6BQSMlLt9rDB4LoSMx0rYwww==", 214 | "hasInstallScript": true, 215 | "dependencies": { 216 | "@mapbox/node-pre-gyp": "^1.0.11", 217 | "node-addon-api": "^5.0.0" 218 | }, 219 | "engines": { 220 | "node": ">= 10.0.0" 221 | } 222 | }, 223 | "node_modules/binary-extensions": { 224 | "version": "2.2.0", 225 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", 226 | "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", 227 | "dev": true, 228 | "engines": { 229 | "node": ">=8" 230 | } 231 | }, 232 | "node_modules/body-parser": { 233 | "version": "1.20.1", 234 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", 235 | "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", 236 | "dependencies": { 237 | "bytes": "3.1.2", 238 | "content-type": "~1.0.4", 239 | "debug": "2.6.9", 240 | "depd": "2.0.0", 241 | "destroy": "1.2.0", 242 | "http-errors": "2.0.0", 243 | "iconv-lite": "0.4.24", 244 | "on-finished": "2.4.1", 245 | "qs": "6.11.0", 246 | "raw-body": "2.5.1", 247 | "type-is": "~1.6.18", 248 | "unpipe": "1.0.0" 249 | }, 250 | "engines": { 251 | "node": ">= 0.8", 252 | "npm": "1.2.8000 || >= 1.4.16" 253 | } 254 | }, 255 | "node_modules/body-parser/node_modules/debug": { 256 | "version": "2.6.9", 257 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 258 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 259 | "dependencies": { 260 | "ms": "2.0.0" 261 | } 262 | }, 263 | "node_modules/body-parser/node_modules/ms": { 264 | "version": "2.0.0", 265 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 266 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 267 | }, 268 | "node_modules/brace-expansion": { 269 | "version": "1.1.11", 270 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 271 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 272 | "dependencies": { 273 | "balanced-match": "^1.0.0", 274 | "concat-map": "0.0.1" 275 | } 276 | }, 277 | "node_modules/braces": { 278 | "version": "3.0.2", 279 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 280 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 281 | "dev": true, 282 | "dependencies": { 283 | "fill-range": "^7.0.1" 284 | }, 285 | "engines": { 286 | "node": ">=8" 287 | } 288 | }, 289 | "node_modules/bson": { 290 | "version": "6.2.0", 291 | "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", 292 | "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", 293 | "engines": { 294 | "node": ">=16.20.1" 295 | } 296 | }, 297 | "node_modules/buffer-equal-constant-time": { 298 | "version": "1.0.1", 299 | "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", 300 | "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" 301 | }, 302 | "node_modules/buffer-from": { 303 | "version": "1.1.2", 304 | "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", 305 | "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" 306 | }, 307 | "node_modules/busboy": { 308 | "version": "1.6.0", 309 | "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", 310 | "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", 311 | "dependencies": { 312 | "streamsearch": "^1.1.0" 313 | }, 314 | "engines": { 315 | "node": ">=10.16.0" 316 | } 317 | }, 318 | "node_modules/bytes": { 319 | "version": "3.1.2", 320 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", 321 | "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", 322 | "engines": { 323 | "node": ">= 0.8" 324 | } 325 | }, 326 | "node_modules/call-bind": { 327 | "version": "1.0.5", 328 | "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", 329 | "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", 330 | "dependencies": { 331 | "function-bind": "^1.1.2", 332 | "get-intrinsic": "^1.2.1", 333 | "set-function-length": "^1.1.1" 334 | }, 335 | "funding": { 336 | "url": "https://github.com/sponsors/ljharb" 337 | } 338 | }, 339 | "node_modules/chokidar": { 340 | "version": "3.5.3", 341 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", 342 | "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", 343 | "dev": true, 344 | "funding": [ 345 | { 346 | "type": "individual", 347 | "url": "https://paulmillr.com/funding/" 348 | } 349 | ], 350 | "dependencies": { 351 | "anymatch": "~3.1.2", 352 | "braces": "~3.0.2", 353 | "glob-parent": "~5.1.2", 354 | "is-binary-path": "~2.1.0", 355 | "is-glob": "~4.0.1", 356 | "normalize-path": "~3.0.0", 357 | "readdirp": "~3.6.0" 358 | }, 359 | "engines": { 360 | "node": ">= 8.10.0" 361 | }, 362 | "optionalDependencies": { 363 | "fsevents": "~2.3.2" 364 | } 365 | }, 366 | "node_modules/chownr": { 367 | "version": "2.0.0", 368 | "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", 369 | "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", 370 | "engines": { 371 | "node": ">=10" 372 | } 373 | }, 374 | "node_modules/cloudinary": { 375 | "version": "1.41.0", 376 | "resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.41.0.tgz", 377 | "integrity": "sha512-qFf2McjvILJITePf4VF1PrY/8c2zy+/q5FVV6V3VWrP/gpIZsusPqXL4QZ6ZKXibPRukzMYqsQEhaSQgJHKKow==", 378 | "dependencies": { 379 | "cloudinary-core": "^2.13.0", 380 | "core-js": "^3.30.1", 381 | "lodash": "^4.17.21", 382 | "q": "^1.5.1" 383 | }, 384 | "engines": { 385 | "node": ">=0.6" 386 | } 387 | }, 388 | "node_modules/cloudinary-core": { 389 | "version": "2.13.0", 390 | "resolved": "https://registry.npmjs.org/cloudinary-core/-/cloudinary-core-2.13.0.tgz", 391 | "integrity": "sha512-Nt0Q5I2FtenmJghtC4YZ3MZZbGg1wLm84SsxcuVwZ83OyJqG9CNIGp86CiI6iDv3QobaqBUpOT7vg+HqY5HxEA==", 392 | "peerDependencies": { 393 | "lodash": ">=4.0" 394 | } 395 | }, 396 | "node_modules/color-support": { 397 | "version": "1.1.3", 398 | "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", 399 | "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", 400 | "bin": { 401 | "color-support": "bin.js" 402 | } 403 | }, 404 | "node_modules/concat-map": { 405 | "version": "0.0.1", 406 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 407 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" 408 | }, 409 | "node_modules/concat-stream": { 410 | "version": "1.6.2", 411 | "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", 412 | "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", 413 | "engines": [ 414 | "node >= 0.8" 415 | ], 416 | "dependencies": { 417 | "buffer-from": "^1.0.0", 418 | "inherits": "^2.0.3", 419 | "readable-stream": "^2.2.2", 420 | "typedarray": "^0.0.6" 421 | } 422 | }, 423 | "node_modules/concat-stream/node_modules/readable-stream": { 424 | "version": "2.3.8", 425 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", 426 | "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", 427 | "dependencies": { 428 | "core-util-is": "~1.0.0", 429 | "inherits": "~2.0.3", 430 | "isarray": "~1.0.0", 431 | "process-nextick-args": "~2.0.0", 432 | "safe-buffer": "~5.1.1", 433 | "string_decoder": "~1.1.1", 434 | "util-deprecate": "~1.0.1" 435 | } 436 | }, 437 | "node_modules/concat-stream/node_modules/safe-buffer": { 438 | "version": "5.1.2", 439 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 440 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 441 | }, 442 | "node_modules/concat-stream/node_modules/string_decoder": { 443 | "version": "1.1.1", 444 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", 445 | "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", 446 | "dependencies": { 447 | "safe-buffer": "~5.1.0" 448 | } 449 | }, 450 | "node_modules/console-control-strings": { 451 | "version": "1.1.0", 452 | "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", 453 | "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" 454 | }, 455 | "node_modules/content-disposition": { 456 | "version": "0.5.4", 457 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", 458 | "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", 459 | "dependencies": { 460 | "safe-buffer": "5.2.1" 461 | }, 462 | "engines": { 463 | "node": ">= 0.6" 464 | } 465 | }, 466 | "node_modules/content-type": { 467 | "version": "1.0.5", 468 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", 469 | "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", 470 | "engines": { 471 | "node": ">= 0.6" 472 | } 473 | }, 474 | "node_modules/cookie": { 475 | "version": "0.5.0", 476 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", 477 | "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", 478 | "engines": { 479 | "node": ">= 0.6" 480 | } 481 | }, 482 | "node_modules/cookie-parser": { 483 | "version": "1.4.6", 484 | "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.6.tgz", 485 | "integrity": "sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA==", 486 | "dependencies": { 487 | "cookie": "0.4.1", 488 | "cookie-signature": "1.0.6" 489 | }, 490 | "engines": { 491 | "node": ">= 0.8.0" 492 | } 493 | }, 494 | "node_modules/cookie-parser/node_modules/cookie": { 495 | "version": "0.4.1", 496 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", 497 | "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", 498 | "engines": { 499 | "node": ">= 0.6" 500 | } 501 | }, 502 | "node_modules/cookie-signature": { 503 | "version": "1.0.6", 504 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 505 | "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" 506 | }, 507 | "node_modules/core-js": { 508 | "version": "3.33.2", 509 | "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.33.2.tgz", 510 | "integrity": "sha512-XeBzWI6QL3nJQiHmdzbAOiMYqjrb7hwU7A39Qhvd/POSa/t9E1AeZyEZx3fNvp/vtM8zXwhoL0FsiS0hD0pruQ==", 511 | "hasInstallScript": true, 512 | "funding": { 513 | "type": "opencollective", 514 | "url": "https://opencollective.com/core-js" 515 | } 516 | }, 517 | "node_modules/core-util-is": { 518 | "version": "1.0.3", 519 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", 520 | "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" 521 | }, 522 | "node_modules/cors": { 523 | "version": "2.8.5", 524 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", 525 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", 526 | "dependencies": { 527 | "object-assign": "^4", 528 | "vary": "^1" 529 | }, 530 | "engines": { 531 | "node": ">= 0.10" 532 | } 533 | }, 534 | "node_modules/debug": { 535 | "version": "3.2.7", 536 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", 537 | "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", 538 | "dev": true, 539 | "dependencies": { 540 | "ms": "^2.1.1" 541 | } 542 | }, 543 | "node_modules/define-data-property": { 544 | "version": "1.1.1", 545 | "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", 546 | "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", 547 | "dependencies": { 548 | "get-intrinsic": "^1.2.1", 549 | "gopd": "^1.0.1", 550 | "has-property-descriptors": "^1.0.0" 551 | }, 552 | "engines": { 553 | "node": ">= 0.4" 554 | } 555 | }, 556 | "node_modules/delegates": { 557 | "version": "1.0.0", 558 | "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", 559 | "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==" 560 | }, 561 | "node_modules/depd": { 562 | "version": "2.0.0", 563 | "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", 564 | "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", 565 | "engines": { 566 | "node": ">= 0.8" 567 | } 568 | }, 569 | "node_modules/destroy": { 570 | "version": "1.2.0", 571 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", 572 | "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", 573 | "engines": { 574 | "node": ">= 0.8", 575 | "npm": "1.2.8000 || >= 1.4.16" 576 | } 577 | }, 578 | "node_modules/detect-libc": { 579 | "version": "2.0.2", 580 | "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", 581 | "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", 582 | "engines": { 583 | "node": ">=8" 584 | } 585 | }, 586 | "node_modules/dotenv": { 587 | "version": "16.3.1", 588 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", 589 | "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", 590 | "engines": { 591 | "node": ">=12" 592 | }, 593 | "funding": { 594 | "url": "https://github.com/motdotla/dotenv?sponsor=1" 595 | } 596 | }, 597 | "node_modules/ecdsa-sig-formatter": { 598 | "version": "1.0.11", 599 | "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", 600 | "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", 601 | "dependencies": { 602 | "safe-buffer": "^5.0.1" 603 | } 604 | }, 605 | "node_modules/ee-first": { 606 | "version": "1.1.1", 607 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 608 | "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" 609 | }, 610 | "node_modules/emoji-regex": { 611 | "version": "8.0.0", 612 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", 613 | "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" 614 | }, 615 | "node_modules/encodeurl": { 616 | "version": "1.0.2", 617 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 618 | "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", 619 | "engines": { 620 | "node": ">= 0.8" 621 | } 622 | }, 623 | "node_modules/escape-html": { 624 | "version": "1.0.3", 625 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 626 | "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" 627 | }, 628 | "node_modules/etag": { 629 | "version": "1.8.1", 630 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 631 | "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", 632 | "engines": { 633 | "node": ">= 0.6" 634 | } 635 | }, 636 | "node_modules/express": { 637 | "version": "4.18.2", 638 | "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", 639 | "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", 640 | "dependencies": { 641 | "accepts": "~1.3.8", 642 | "array-flatten": "1.1.1", 643 | "body-parser": "1.20.1", 644 | "content-disposition": "0.5.4", 645 | "content-type": "~1.0.4", 646 | "cookie": "0.5.0", 647 | "cookie-signature": "1.0.6", 648 | "debug": "2.6.9", 649 | "depd": "2.0.0", 650 | "encodeurl": "~1.0.2", 651 | "escape-html": "~1.0.3", 652 | "etag": "~1.8.1", 653 | "finalhandler": "1.2.0", 654 | "fresh": "0.5.2", 655 | "http-errors": "2.0.0", 656 | "merge-descriptors": "1.0.1", 657 | "methods": "~1.1.2", 658 | "on-finished": "2.4.1", 659 | "parseurl": "~1.3.3", 660 | "path-to-regexp": "0.1.7", 661 | "proxy-addr": "~2.0.7", 662 | "qs": "6.11.0", 663 | "range-parser": "~1.2.1", 664 | "safe-buffer": "5.2.1", 665 | "send": "0.18.0", 666 | "serve-static": "1.15.0", 667 | "setprototypeof": "1.2.0", 668 | "statuses": "2.0.1", 669 | "type-is": "~1.6.18", 670 | "utils-merge": "1.0.1", 671 | "vary": "~1.1.2" 672 | }, 673 | "engines": { 674 | "node": ">= 0.10.0" 675 | } 676 | }, 677 | "node_modules/express/node_modules/debug": { 678 | "version": "2.6.9", 679 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 680 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 681 | "dependencies": { 682 | "ms": "2.0.0" 683 | } 684 | }, 685 | "node_modules/express/node_modules/ms": { 686 | "version": "2.0.0", 687 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 688 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 689 | }, 690 | "node_modules/fill-range": { 691 | "version": "7.0.1", 692 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 693 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 694 | "dev": true, 695 | "dependencies": { 696 | "to-regex-range": "^5.0.1" 697 | }, 698 | "engines": { 699 | "node": ">=8" 700 | } 701 | }, 702 | "node_modules/finalhandler": { 703 | "version": "1.2.0", 704 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", 705 | "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", 706 | "dependencies": { 707 | "debug": "2.6.9", 708 | "encodeurl": "~1.0.2", 709 | "escape-html": "~1.0.3", 710 | "on-finished": "2.4.1", 711 | "parseurl": "~1.3.3", 712 | "statuses": "2.0.1", 713 | "unpipe": "~1.0.0" 714 | }, 715 | "engines": { 716 | "node": ">= 0.8" 717 | } 718 | }, 719 | "node_modules/finalhandler/node_modules/debug": { 720 | "version": "2.6.9", 721 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 722 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 723 | "dependencies": { 724 | "ms": "2.0.0" 725 | } 726 | }, 727 | "node_modules/finalhandler/node_modules/ms": { 728 | "version": "2.0.0", 729 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 730 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 731 | }, 732 | "node_modules/forwarded": { 733 | "version": "0.2.0", 734 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", 735 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", 736 | "engines": { 737 | "node": ">= 0.6" 738 | } 739 | }, 740 | "node_modules/fresh": { 741 | "version": "0.5.2", 742 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 743 | "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", 744 | "engines": { 745 | "node": ">= 0.6" 746 | } 747 | }, 748 | "node_modules/fs-minipass": { 749 | "version": "2.1.0", 750 | "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", 751 | "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", 752 | "dependencies": { 753 | "minipass": "^3.0.0" 754 | }, 755 | "engines": { 756 | "node": ">= 8" 757 | } 758 | }, 759 | "node_modules/fs-minipass/node_modules/minipass": { 760 | "version": "3.3.6", 761 | "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", 762 | "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", 763 | "dependencies": { 764 | "yallist": "^4.0.0" 765 | }, 766 | "engines": { 767 | "node": ">=8" 768 | } 769 | }, 770 | "node_modules/fs.realpath": { 771 | "version": "1.0.0", 772 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 773 | "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" 774 | }, 775 | "node_modules/fsevents": { 776 | "version": "2.3.3", 777 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", 778 | "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", 779 | "dev": true, 780 | "hasInstallScript": true, 781 | "optional": true, 782 | "os": [ 783 | "darwin" 784 | ], 785 | "engines": { 786 | "node": "^8.16.0 || ^10.6.0 || >=11.0.0" 787 | } 788 | }, 789 | "node_modules/function-bind": { 790 | "version": "1.1.2", 791 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", 792 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", 793 | "funding": { 794 | "url": "https://github.com/sponsors/ljharb" 795 | } 796 | }, 797 | "node_modules/gauge": { 798 | "version": "3.0.2", 799 | "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", 800 | "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", 801 | "dependencies": { 802 | "aproba": "^1.0.3 || ^2.0.0", 803 | "color-support": "^1.1.2", 804 | "console-control-strings": "^1.0.0", 805 | "has-unicode": "^2.0.1", 806 | "object-assign": "^4.1.1", 807 | "signal-exit": "^3.0.0", 808 | "string-width": "^4.2.3", 809 | "strip-ansi": "^6.0.1", 810 | "wide-align": "^1.1.2" 811 | }, 812 | "engines": { 813 | "node": ">=10" 814 | } 815 | }, 816 | "node_modules/get-intrinsic": { 817 | "version": "1.2.2", 818 | "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", 819 | "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", 820 | "dependencies": { 821 | "function-bind": "^1.1.2", 822 | "has-proto": "^1.0.1", 823 | "has-symbols": "^1.0.3", 824 | "hasown": "^2.0.0" 825 | }, 826 | "funding": { 827 | "url": "https://github.com/sponsors/ljharb" 828 | } 829 | }, 830 | "node_modules/glob": { 831 | "version": "7.2.3", 832 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", 833 | "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", 834 | "dependencies": { 835 | "fs.realpath": "^1.0.0", 836 | "inflight": "^1.0.4", 837 | "inherits": "2", 838 | "minimatch": "^3.1.1", 839 | "once": "^1.3.0", 840 | "path-is-absolute": "^1.0.0" 841 | }, 842 | "engines": { 843 | "node": "*" 844 | }, 845 | "funding": { 846 | "url": "https://github.com/sponsors/isaacs" 847 | } 848 | }, 849 | "node_modules/glob-parent": { 850 | "version": "5.1.2", 851 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 852 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 853 | "dev": true, 854 | "dependencies": { 855 | "is-glob": "^4.0.1" 856 | }, 857 | "engines": { 858 | "node": ">= 6" 859 | } 860 | }, 861 | "node_modules/gopd": { 862 | "version": "1.0.1", 863 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", 864 | "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", 865 | "dependencies": { 866 | "get-intrinsic": "^1.1.3" 867 | }, 868 | "funding": { 869 | "url": "https://github.com/sponsors/ljharb" 870 | } 871 | }, 872 | "node_modules/has-flag": { 873 | "version": "3.0.0", 874 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 875 | "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", 876 | "dev": true, 877 | "engines": { 878 | "node": ">=4" 879 | } 880 | }, 881 | "node_modules/has-property-descriptors": { 882 | "version": "1.0.1", 883 | "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", 884 | "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", 885 | "dependencies": { 886 | "get-intrinsic": "^1.2.2" 887 | }, 888 | "funding": { 889 | "url": "https://github.com/sponsors/ljharb" 890 | } 891 | }, 892 | "node_modules/has-proto": { 893 | "version": "1.0.1", 894 | "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", 895 | "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", 896 | "engines": { 897 | "node": ">= 0.4" 898 | }, 899 | "funding": { 900 | "url": "https://github.com/sponsors/ljharb" 901 | } 902 | }, 903 | "node_modules/has-symbols": { 904 | "version": "1.0.3", 905 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", 906 | "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", 907 | "engines": { 908 | "node": ">= 0.4" 909 | }, 910 | "funding": { 911 | "url": "https://github.com/sponsors/ljharb" 912 | } 913 | }, 914 | "node_modules/has-unicode": { 915 | "version": "2.0.1", 916 | "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", 917 | "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" 918 | }, 919 | "node_modules/hasown": { 920 | "version": "2.0.0", 921 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", 922 | "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", 923 | "dependencies": { 924 | "function-bind": "^1.1.2" 925 | }, 926 | "engines": { 927 | "node": ">= 0.4" 928 | } 929 | }, 930 | "node_modules/http-errors": { 931 | "version": "2.0.0", 932 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", 933 | "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", 934 | "dependencies": { 935 | "depd": "2.0.0", 936 | "inherits": "2.0.4", 937 | "setprototypeof": "1.2.0", 938 | "statuses": "2.0.1", 939 | "toidentifier": "1.0.1" 940 | }, 941 | "engines": { 942 | "node": ">= 0.8" 943 | } 944 | }, 945 | "node_modules/https-proxy-agent": { 946 | "version": "5.0.1", 947 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", 948 | "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", 949 | "dependencies": { 950 | "agent-base": "6", 951 | "debug": "4" 952 | }, 953 | "engines": { 954 | "node": ">= 6" 955 | } 956 | }, 957 | "node_modules/https-proxy-agent/node_modules/debug": { 958 | "version": "4.3.4", 959 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 960 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 961 | "dependencies": { 962 | "ms": "2.1.2" 963 | }, 964 | "engines": { 965 | "node": ">=6.0" 966 | }, 967 | "peerDependenciesMeta": { 968 | "supports-color": { 969 | "optional": true 970 | } 971 | } 972 | }, 973 | "node_modules/https-proxy-agent/node_modules/ms": { 974 | "version": "2.1.2", 975 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 976 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 977 | }, 978 | "node_modules/iconv-lite": { 979 | "version": "0.4.24", 980 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 981 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 982 | "dependencies": { 983 | "safer-buffer": ">= 2.1.2 < 3" 984 | }, 985 | "engines": { 986 | "node": ">=0.10.0" 987 | } 988 | }, 989 | "node_modules/ignore-by-default": { 990 | "version": "1.0.1", 991 | "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", 992 | "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", 993 | "dev": true 994 | }, 995 | "node_modules/inflight": { 996 | "version": "1.0.6", 997 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 998 | "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", 999 | "dependencies": { 1000 | "once": "^1.3.0", 1001 | "wrappy": "1" 1002 | } 1003 | }, 1004 | "node_modules/inherits": { 1005 | "version": "2.0.4", 1006 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 1007 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 1008 | }, 1009 | "node_modules/ipaddr.js": { 1010 | "version": "1.9.1", 1011 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", 1012 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", 1013 | "engines": { 1014 | "node": ">= 0.10" 1015 | } 1016 | }, 1017 | "node_modules/is-binary-path": { 1018 | "version": "2.1.0", 1019 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", 1020 | "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", 1021 | "dev": true, 1022 | "dependencies": { 1023 | "binary-extensions": "^2.0.0" 1024 | }, 1025 | "engines": { 1026 | "node": ">=8" 1027 | } 1028 | }, 1029 | "node_modules/is-extglob": { 1030 | "version": "2.1.1", 1031 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 1032 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 1033 | "dev": true, 1034 | "engines": { 1035 | "node": ">=0.10.0" 1036 | } 1037 | }, 1038 | "node_modules/is-fullwidth-code-point": { 1039 | "version": "3.0.0", 1040 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", 1041 | "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", 1042 | "engines": { 1043 | "node": ">=8" 1044 | } 1045 | }, 1046 | "node_modules/is-glob": { 1047 | "version": "4.0.3", 1048 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 1049 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 1050 | "dev": true, 1051 | "dependencies": { 1052 | "is-extglob": "^2.1.1" 1053 | }, 1054 | "engines": { 1055 | "node": ">=0.10.0" 1056 | } 1057 | }, 1058 | "node_modules/is-number": { 1059 | "version": "7.0.0", 1060 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 1061 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 1062 | "dev": true, 1063 | "engines": { 1064 | "node": ">=0.12.0" 1065 | } 1066 | }, 1067 | "node_modules/isarray": { 1068 | "version": "1.0.0", 1069 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 1070 | "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" 1071 | }, 1072 | "node_modules/jsonwebtoken": { 1073 | "version": "9.0.2", 1074 | "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", 1075 | "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", 1076 | "dependencies": { 1077 | "jws": "^3.2.2", 1078 | "lodash.includes": "^4.3.0", 1079 | "lodash.isboolean": "^3.0.3", 1080 | "lodash.isinteger": "^4.0.4", 1081 | "lodash.isnumber": "^3.0.3", 1082 | "lodash.isplainobject": "^4.0.6", 1083 | "lodash.isstring": "^4.0.1", 1084 | "lodash.once": "^4.0.0", 1085 | "ms": "^2.1.1", 1086 | "semver": "^7.5.4" 1087 | }, 1088 | "engines": { 1089 | "node": ">=12", 1090 | "npm": ">=6" 1091 | } 1092 | }, 1093 | "node_modules/jwa": { 1094 | "version": "1.4.1", 1095 | "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", 1096 | "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", 1097 | "dependencies": { 1098 | "buffer-equal-constant-time": "1.0.1", 1099 | "ecdsa-sig-formatter": "1.0.11", 1100 | "safe-buffer": "^5.0.1" 1101 | } 1102 | }, 1103 | "node_modules/jws": { 1104 | "version": "3.2.2", 1105 | "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", 1106 | "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", 1107 | "dependencies": { 1108 | "jwa": "^1.4.1", 1109 | "safe-buffer": "^5.0.1" 1110 | } 1111 | }, 1112 | "node_modules/kareem": { 1113 | "version": "2.5.1", 1114 | "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", 1115 | "integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==", 1116 | "engines": { 1117 | "node": ">=12.0.0" 1118 | } 1119 | }, 1120 | "node_modules/lodash": { 1121 | "version": "4.17.21", 1122 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", 1123 | "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" 1124 | }, 1125 | "node_modules/lodash.includes": { 1126 | "version": "4.3.0", 1127 | "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", 1128 | "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==" 1129 | }, 1130 | "node_modules/lodash.isboolean": { 1131 | "version": "3.0.3", 1132 | "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", 1133 | "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==" 1134 | }, 1135 | "node_modules/lodash.isinteger": { 1136 | "version": "4.0.4", 1137 | "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", 1138 | "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==" 1139 | }, 1140 | "node_modules/lodash.isnumber": { 1141 | "version": "3.0.3", 1142 | "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", 1143 | "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==" 1144 | }, 1145 | "node_modules/lodash.isplainobject": { 1146 | "version": "4.0.6", 1147 | "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", 1148 | "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==" 1149 | }, 1150 | "node_modules/lodash.isstring": { 1151 | "version": "4.0.1", 1152 | "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", 1153 | "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==" 1154 | }, 1155 | "node_modules/lodash.once": { 1156 | "version": "4.1.1", 1157 | "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", 1158 | "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==" 1159 | }, 1160 | "node_modules/lru-cache": { 1161 | "version": "6.0.0", 1162 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 1163 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 1164 | "dependencies": { 1165 | "yallist": "^4.0.0" 1166 | }, 1167 | "engines": { 1168 | "node": ">=10" 1169 | } 1170 | }, 1171 | "node_modules/make-dir": { 1172 | "version": "3.1.0", 1173 | "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", 1174 | "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", 1175 | "dependencies": { 1176 | "semver": "^6.0.0" 1177 | }, 1178 | "engines": { 1179 | "node": ">=8" 1180 | }, 1181 | "funding": { 1182 | "url": "https://github.com/sponsors/sindresorhus" 1183 | } 1184 | }, 1185 | "node_modules/make-dir/node_modules/semver": { 1186 | "version": "6.3.1", 1187 | "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", 1188 | "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", 1189 | "bin": { 1190 | "semver": "bin/semver.js" 1191 | } 1192 | }, 1193 | "node_modules/media-typer": { 1194 | "version": "0.3.0", 1195 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 1196 | "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", 1197 | "engines": { 1198 | "node": ">= 0.6" 1199 | } 1200 | }, 1201 | "node_modules/memory-pager": { 1202 | "version": "1.5.0", 1203 | "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", 1204 | "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==" 1205 | }, 1206 | "node_modules/merge-descriptors": { 1207 | "version": "1.0.1", 1208 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 1209 | "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" 1210 | }, 1211 | "node_modules/methods": { 1212 | "version": "1.1.2", 1213 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 1214 | "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", 1215 | "engines": { 1216 | "node": ">= 0.6" 1217 | } 1218 | }, 1219 | "node_modules/mime": { 1220 | "version": "1.6.0", 1221 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", 1222 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", 1223 | "bin": { 1224 | "mime": "cli.js" 1225 | }, 1226 | "engines": { 1227 | "node": ">=4" 1228 | } 1229 | }, 1230 | "node_modules/mime-db": { 1231 | "version": "1.52.0", 1232 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 1233 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 1234 | "engines": { 1235 | "node": ">= 0.6" 1236 | } 1237 | }, 1238 | "node_modules/mime-types": { 1239 | "version": "2.1.35", 1240 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 1241 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 1242 | "dependencies": { 1243 | "mime-db": "1.52.0" 1244 | }, 1245 | "engines": { 1246 | "node": ">= 0.6" 1247 | } 1248 | }, 1249 | "node_modules/minimatch": { 1250 | "version": "3.1.2", 1251 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 1252 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 1253 | "dependencies": { 1254 | "brace-expansion": "^1.1.7" 1255 | }, 1256 | "engines": { 1257 | "node": "*" 1258 | } 1259 | }, 1260 | "node_modules/minimist": { 1261 | "version": "1.2.8", 1262 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", 1263 | "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", 1264 | "funding": { 1265 | "url": "https://github.com/sponsors/ljharb" 1266 | } 1267 | }, 1268 | "node_modules/minipass": { 1269 | "version": "5.0.0", 1270 | "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", 1271 | "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", 1272 | "engines": { 1273 | "node": ">=8" 1274 | } 1275 | }, 1276 | "node_modules/minizlib": { 1277 | "version": "2.1.2", 1278 | "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", 1279 | "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", 1280 | "dependencies": { 1281 | "minipass": "^3.0.0", 1282 | "yallist": "^4.0.0" 1283 | }, 1284 | "engines": { 1285 | "node": ">= 8" 1286 | } 1287 | }, 1288 | "node_modules/minizlib/node_modules/minipass": { 1289 | "version": "3.3.6", 1290 | "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", 1291 | "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", 1292 | "dependencies": { 1293 | "yallist": "^4.0.0" 1294 | }, 1295 | "engines": { 1296 | "node": ">=8" 1297 | } 1298 | }, 1299 | "node_modules/mkdirp": { 1300 | "version": "1.0.4", 1301 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", 1302 | "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", 1303 | "bin": { 1304 | "mkdirp": "bin/cmd.js" 1305 | }, 1306 | "engines": { 1307 | "node": ">=10" 1308 | } 1309 | }, 1310 | "node_modules/mongodb": { 1311 | "version": "6.2.0", 1312 | "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.2.0.tgz", 1313 | "integrity": "sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==", 1314 | "dependencies": { 1315 | "@mongodb-js/saslprep": "^1.1.0", 1316 | "bson": "^6.2.0", 1317 | "mongodb-connection-string-url": "^2.6.0" 1318 | }, 1319 | "engines": { 1320 | "node": ">=16.20.1" 1321 | }, 1322 | "peerDependencies": { 1323 | "@aws-sdk/credential-providers": "^3.188.0", 1324 | "@mongodb-js/zstd": "^1.1.0", 1325 | "gcp-metadata": "^5.2.0", 1326 | "kerberos": "^2.0.1", 1327 | "mongodb-client-encryption": ">=6.0.0 <7", 1328 | "snappy": "^7.2.2", 1329 | "socks": "^2.7.1" 1330 | }, 1331 | "peerDependenciesMeta": { 1332 | "@aws-sdk/credential-providers": { 1333 | "optional": true 1334 | }, 1335 | "@mongodb-js/zstd": { 1336 | "optional": true 1337 | }, 1338 | "gcp-metadata": { 1339 | "optional": true 1340 | }, 1341 | "kerberos": { 1342 | "optional": true 1343 | }, 1344 | "mongodb-client-encryption": { 1345 | "optional": true 1346 | }, 1347 | "snappy": { 1348 | "optional": true 1349 | }, 1350 | "socks": { 1351 | "optional": true 1352 | } 1353 | } 1354 | }, 1355 | "node_modules/mongodb-connection-string-url": { 1356 | "version": "2.6.0", 1357 | "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.6.0.tgz", 1358 | "integrity": "sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ==", 1359 | "dependencies": { 1360 | "@types/whatwg-url": "^8.2.1", 1361 | "whatwg-url": "^11.0.0" 1362 | } 1363 | }, 1364 | "node_modules/mongoose": { 1365 | "version": "8.0.0", 1366 | "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.0.0.tgz", 1367 | "integrity": "sha512-PzwkLgm1Jhj0NQdgGfnFsu0QP9V1sBFgbavEgh/IPAUzKAagzvEhuaBuAQOQGjczVWnpIU9tBqyd02cOTgsPlA==", 1368 | "dependencies": { 1369 | "bson": "^6.2.0", 1370 | "kareem": "2.5.1", 1371 | "mongodb": "6.2.0", 1372 | "mpath": "0.9.0", 1373 | "mquery": "5.0.0", 1374 | "ms": "2.1.3", 1375 | "sift": "16.0.1" 1376 | }, 1377 | "engines": { 1378 | "node": ">=16.20.1" 1379 | }, 1380 | "funding": { 1381 | "type": "opencollective", 1382 | "url": "https://opencollective.com/mongoose" 1383 | } 1384 | }, 1385 | "node_modules/mongoose-aggregate-paginate-v2": { 1386 | "version": "1.0.6", 1387 | "resolved": "https://registry.npmjs.org/mongoose-aggregate-paginate-v2/-/mongoose-aggregate-paginate-v2-1.0.6.tgz", 1388 | "integrity": "sha512-UuALu+mjhQa1K9lMQvjLL3vm3iALvNw8PQNIh2gp1b+tO5hUa0NC0Wf6/8QrT9PSJVTihXaD8hQVy3J4e0jO0Q==", 1389 | "engines": { 1390 | "node": ">=4.0.0" 1391 | } 1392 | }, 1393 | "node_modules/morgan": { 1394 | "version": "1.10.0", 1395 | "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", 1396 | "integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==", 1397 | "dependencies": { 1398 | "basic-auth": "~2.0.1", 1399 | "debug": "2.6.9", 1400 | "depd": "~2.0.0", 1401 | "on-finished": "~2.3.0", 1402 | "on-headers": "~1.0.2" 1403 | }, 1404 | "engines": { 1405 | "node": ">= 0.8.0" 1406 | } 1407 | }, 1408 | "node_modules/morgan/node_modules/debug": { 1409 | "version": "2.6.9", 1410 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 1411 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 1412 | "dependencies": { 1413 | "ms": "2.0.0" 1414 | } 1415 | }, 1416 | "node_modules/morgan/node_modules/ms": { 1417 | "version": "2.0.0", 1418 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 1419 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 1420 | }, 1421 | "node_modules/morgan/node_modules/on-finished": { 1422 | "version": "2.3.0", 1423 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 1424 | "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", 1425 | "dependencies": { 1426 | "ee-first": "1.1.1" 1427 | }, 1428 | "engines": { 1429 | "node": ">= 0.8" 1430 | } 1431 | }, 1432 | "node_modules/mpath": { 1433 | "version": "0.9.0", 1434 | "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", 1435 | "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", 1436 | "engines": { 1437 | "node": ">=4.0.0" 1438 | } 1439 | }, 1440 | "node_modules/mquery": { 1441 | "version": "5.0.0", 1442 | "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", 1443 | "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", 1444 | "dependencies": { 1445 | "debug": "4.x" 1446 | }, 1447 | "engines": { 1448 | "node": ">=14.0.0" 1449 | } 1450 | }, 1451 | "node_modules/mquery/node_modules/debug": { 1452 | "version": "4.3.4", 1453 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 1454 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 1455 | "dependencies": { 1456 | "ms": "2.1.2" 1457 | }, 1458 | "engines": { 1459 | "node": ">=6.0" 1460 | }, 1461 | "peerDependenciesMeta": { 1462 | "supports-color": { 1463 | "optional": true 1464 | } 1465 | } 1466 | }, 1467 | "node_modules/mquery/node_modules/ms": { 1468 | "version": "2.1.2", 1469 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 1470 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 1471 | }, 1472 | "node_modules/ms": { 1473 | "version": "2.1.3", 1474 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 1475 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 1476 | }, 1477 | "node_modules/multer": { 1478 | "version": "1.4.5-lts.1", 1479 | "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", 1480 | "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", 1481 | "dependencies": { 1482 | "append-field": "^1.0.0", 1483 | "busboy": "^1.0.0", 1484 | "concat-stream": "^1.5.2", 1485 | "mkdirp": "^0.5.4", 1486 | "object-assign": "^4.1.1", 1487 | "type-is": "^1.6.4", 1488 | "xtend": "^4.0.0" 1489 | }, 1490 | "engines": { 1491 | "node": ">= 6.0.0" 1492 | } 1493 | }, 1494 | "node_modules/multer/node_modules/mkdirp": { 1495 | "version": "0.5.6", 1496 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", 1497 | "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", 1498 | "dependencies": { 1499 | "minimist": "^1.2.6" 1500 | }, 1501 | "bin": { 1502 | "mkdirp": "bin/cmd.js" 1503 | } 1504 | }, 1505 | "node_modules/negotiator": { 1506 | "version": "0.6.3", 1507 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", 1508 | "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", 1509 | "engines": { 1510 | "node": ">= 0.6" 1511 | } 1512 | }, 1513 | "node_modules/node-addon-api": { 1514 | "version": "5.1.0", 1515 | "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", 1516 | "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==" 1517 | }, 1518 | "node_modules/node-fetch": { 1519 | "version": "2.7.0", 1520 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", 1521 | "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", 1522 | "dependencies": { 1523 | "whatwg-url": "^5.0.0" 1524 | }, 1525 | "engines": { 1526 | "node": "4.x || >=6.0.0" 1527 | }, 1528 | "peerDependencies": { 1529 | "encoding": "^0.1.0" 1530 | }, 1531 | "peerDependenciesMeta": { 1532 | "encoding": { 1533 | "optional": true 1534 | } 1535 | } 1536 | }, 1537 | "node_modules/node-fetch/node_modules/tr46": { 1538 | "version": "0.0.3", 1539 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 1540 | "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" 1541 | }, 1542 | "node_modules/node-fetch/node_modules/webidl-conversions": { 1543 | "version": "3.0.1", 1544 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 1545 | "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" 1546 | }, 1547 | "node_modules/node-fetch/node_modules/whatwg-url": { 1548 | "version": "5.0.0", 1549 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 1550 | "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", 1551 | "dependencies": { 1552 | "tr46": "~0.0.3", 1553 | "webidl-conversions": "^3.0.0" 1554 | } 1555 | }, 1556 | "node_modules/nodemon": { 1557 | "version": "3.0.1", 1558 | "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", 1559 | "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", 1560 | "dev": true, 1561 | "dependencies": { 1562 | "chokidar": "^3.5.2", 1563 | "debug": "^3.2.7", 1564 | "ignore-by-default": "^1.0.1", 1565 | "minimatch": "^3.1.2", 1566 | "pstree.remy": "^1.1.8", 1567 | "semver": "^7.5.3", 1568 | "simple-update-notifier": "^2.0.0", 1569 | "supports-color": "^5.5.0", 1570 | "touch": "^3.1.0", 1571 | "undefsafe": "^2.0.5" 1572 | }, 1573 | "bin": { 1574 | "nodemon": "bin/nodemon.js" 1575 | }, 1576 | "engines": { 1577 | "node": ">=10" 1578 | }, 1579 | "funding": { 1580 | "type": "opencollective", 1581 | "url": "https://opencollective.com/nodemon" 1582 | } 1583 | }, 1584 | "node_modules/nopt": { 1585 | "version": "1.0.10", 1586 | "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", 1587 | "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", 1588 | "dev": true, 1589 | "dependencies": { 1590 | "abbrev": "1" 1591 | }, 1592 | "bin": { 1593 | "nopt": "bin/nopt.js" 1594 | }, 1595 | "engines": { 1596 | "node": "*" 1597 | } 1598 | }, 1599 | "node_modules/normalize-path": { 1600 | "version": "3.0.0", 1601 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", 1602 | "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", 1603 | "dev": true, 1604 | "engines": { 1605 | "node": ">=0.10.0" 1606 | } 1607 | }, 1608 | "node_modules/npmlog": { 1609 | "version": "5.0.1", 1610 | "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", 1611 | "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", 1612 | "dependencies": { 1613 | "are-we-there-yet": "^2.0.0", 1614 | "console-control-strings": "^1.1.0", 1615 | "gauge": "^3.0.0", 1616 | "set-blocking": "^2.0.0" 1617 | } 1618 | }, 1619 | "node_modules/object-assign": { 1620 | "version": "4.1.1", 1621 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 1622 | "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", 1623 | "engines": { 1624 | "node": ">=0.10.0" 1625 | } 1626 | }, 1627 | "node_modules/object-inspect": { 1628 | "version": "1.13.1", 1629 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", 1630 | "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", 1631 | "funding": { 1632 | "url": "https://github.com/sponsors/ljharb" 1633 | } 1634 | }, 1635 | "node_modules/on-finished": { 1636 | "version": "2.4.1", 1637 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", 1638 | "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", 1639 | "dependencies": { 1640 | "ee-first": "1.1.1" 1641 | }, 1642 | "engines": { 1643 | "node": ">= 0.8" 1644 | } 1645 | }, 1646 | "node_modules/on-headers": { 1647 | "version": "1.0.2", 1648 | "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", 1649 | "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", 1650 | "engines": { 1651 | "node": ">= 0.8" 1652 | } 1653 | }, 1654 | "node_modules/once": { 1655 | "version": "1.4.0", 1656 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 1657 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 1658 | "dependencies": { 1659 | "wrappy": "1" 1660 | } 1661 | }, 1662 | "node_modules/parseurl": { 1663 | "version": "1.3.3", 1664 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 1665 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", 1666 | "engines": { 1667 | "node": ">= 0.8" 1668 | } 1669 | }, 1670 | "node_modules/path-is-absolute": { 1671 | "version": "1.0.1", 1672 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 1673 | "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", 1674 | "engines": { 1675 | "node": ">=0.10.0" 1676 | } 1677 | }, 1678 | "node_modules/path-to-regexp": { 1679 | "version": "0.1.7", 1680 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 1681 | "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" 1682 | }, 1683 | "node_modules/picomatch": { 1684 | "version": "2.3.1", 1685 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 1686 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 1687 | "dev": true, 1688 | "engines": { 1689 | "node": ">=8.6" 1690 | }, 1691 | "funding": { 1692 | "url": "https://github.com/sponsors/jonschlinkert" 1693 | } 1694 | }, 1695 | "node_modules/prettier": { 1696 | "version": "3.0.3", 1697 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", 1698 | "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", 1699 | "dev": true, 1700 | "bin": { 1701 | "prettier": "bin/prettier.cjs" 1702 | }, 1703 | "engines": { 1704 | "node": ">=14" 1705 | }, 1706 | "funding": { 1707 | "url": "https://github.com/prettier/prettier?sponsor=1" 1708 | } 1709 | }, 1710 | "node_modules/process-nextick-args": { 1711 | "version": "2.0.1", 1712 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", 1713 | "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" 1714 | }, 1715 | "node_modules/proxy-addr": { 1716 | "version": "2.0.7", 1717 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", 1718 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", 1719 | "dependencies": { 1720 | "forwarded": "0.2.0", 1721 | "ipaddr.js": "1.9.1" 1722 | }, 1723 | "engines": { 1724 | "node": ">= 0.10" 1725 | } 1726 | }, 1727 | "node_modules/pstree.remy": { 1728 | "version": "1.1.8", 1729 | "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", 1730 | "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", 1731 | "dev": true 1732 | }, 1733 | "node_modules/punycode": { 1734 | "version": "2.3.1", 1735 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", 1736 | "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", 1737 | "engines": { 1738 | "node": ">=6" 1739 | } 1740 | }, 1741 | "node_modules/q": { 1742 | "version": "1.5.1", 1743 | "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", 1744 | "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", 1745 | "engines": { 1746 | "node": ">=0.6.0", 1747 | "teleport": ">=0.2.0" 1748 | } 1749 | }, 1750 | "node_modules/qs": { 1751 | "version": "6.11.0", 1752 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", 1753 | "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", 1754 | "dependencies": { 1755 | "side-channel": "^1.0.4" 1756 | }, 1757 | "engines": { 1758 | "node": ">=0.6" 1759 | }, 1760 | "funding": { 1761 | "url": "https://github.com/sponsors/ljharb" 1762 | } 1763 | }, 1764 | "node_modules/range-parser": { 1765 | "version": "1.2.1", 1766 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 1767 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", 1768 | "engines": { 1769 | "node": ">= 0.6" 1770 | } 1771 | }, 1772 | "node_modules/raw-body": { 1773 | "version": "2.5.1", 1774 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", 1775 | "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", 1776 | "dependencies": { 1777 | "bytes": "3.1.2", 1778 | "http-errors": "2.0.0", 1779 | "iconv-lite": "0.4.24", 1780 | "unpipe": "1.0.0" 1781 | }, 1782 | "engines": { 1783 | "node": ">= 0.8" 1784 | } 1785 | }, 1786 | "node_modules/readable-stream": { 1787 | "version": "3.6.2", 1788 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", 1789 | "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", 1790 | "dependencies": { 1791 | "inherits": "^2.0.3", 1792 | "string_decoder": "^1.1.1", 1793 | "util-deprecate": "^1.0.1" 1794 | }, 1795 | "engines": { 1796 | "node": ">= 6" 1797 | } 1798 | }, 1799 | "node_modules/readdirp": { 1800 | "version": "3.6.0", 1801 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", 1802 | "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", 1803 | "dev": true, 1804 | "dependencies": { 1805 | "picomatch": "^2.2.1" 1806 | }, 1807 | "engines": { 1808 | "node": ">=8.10.0" 1809 | } 1810 | }, 1811 | "node_modules/rimraf": { 1812 | "version": "3.0.2", 1813 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", 1814 | "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", 1815 | "dependencies": { 1816 | "glob": "^7.1.3" 1817 | }, 1818 | "bin": { 1819 | "rimraf": "bin.js" 1820 | }, 1821 | "funding": { 1822 | "url": "https://github.com/sponsors/isaacs" 1823 | } 1824 | }, 1825 | "node_modules/safe-buffer": { 1826 | "version": "5.2.1", 1827 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 1828 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", 1829 | "funding": [ 1830 | { 1831 | "type": "github", 1832 | "url": "https://github.com/sponsors/feross" 1833 | }, 1834 | { 1835 | "type": "patreon", 1836 | "url": "https://www.patreon.com/feross" 1837 | }, 1838 | { 1839 | "type": "consulting", 1840 | "url": "https://feross.org/support" 1841 | } 1842 | ] 1843 | }, 1844 | "node_modules/safer-buffer": { 1845 | "version": "2.1.2", 1846 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 1847 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 1848 | }, 1849 | "node_modules/semver": { 1850 | "version": "7.5.4", 1851 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", 1852 | "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", 1853 | "dependencies": { 1854 | "lru-cache": "^6.0.0" 1855 | }, 1856 | "bin": { 1857 | "semver": "bin/semver.js" 1858 | }, 1859 | "engines": { 1860 | "node": ">=10" 1861 | } 1862 | }, 1863 | "node_modules/send": { 1864 | "version": "0.18.0", 1865 | "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", 1866 | "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", 1867 | "dependencies": { 1868 | "debug": "2.6.9", 1869 | "depd": "2.0.0", 1870 | "destroy": "1.2.0", 1871 | "encodeurl": "~1.0.2", 1872 | "escape-html": "~1.0.3", 1873 | "etag": "~1.8.1", 1874 | "fresh": "0.5.2", 1875 | "http-errors": "2.0.0", 1876 | "mime": "1.6.0", 1877 | "ms": "2.1.3", 1878 | "on-finished": "2.4.1", 1879 | "range-parser": "~1.2.1", 1880 | "statuses": "2.0.1" 1881 | }, 1882 | "engines": { 1883 | "node": ">= 0.8.0" 1884 | } 1885 | }, 1886 | "node_modules/send/node_modules/debug": { 1887 | "version": "2.6.9", 1888 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 1889 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 1890 | "dependencies": { 1891 | "ms": "2.0.0" 1892 | } 1893 | }, 1894 | "node_modules/send/node_modules/debug/node_modules/ms": { 1895 | "version": "2.0.0", 1896 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 1897 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 1898 | }, 1899 | "node_modules/serve-static": { 1900 | "version": "1.15.0", 1901 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", 1902 | "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", 1903 | "dependencies": { 1904 | "encodeurl": "~1.0.2", 1905 | "escape-html": "~1.0.3", 1906 | "parseurl": "~1.3.3", 1907 | "send": "0.18.0" 1908 | }, 1909 | "engines": { 1910 | "node": ">= 0.8.0" 1911 | } 1912 | }, 1913 | "node_modules/set-blocking": { 1914 | "version": "2.0.0", 1915 | "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", 1916 | "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" 1917 | }, 1918 | "node_modules/set-function-length": { 1919 | "version": "1.1.1", 1920 | "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", 1921 | "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", 1922 | "dependencies": { 1923 | "define-data-property": "^1.1.1", 1924 | "get-intrinsic": "^1.2.1", 1925 | "gopd": "^1.0.1", 1926 | "has-property-descriptors": "^1.0.0" 1927 | }, 1928 | "engines": { 1929 | "node": ">= 0.4" 1930 | } 1931 | }, 1932 | "node_modules/setprototypeof": { 1933 | "version": "1.2.0", 1934 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", 1935 | "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" 1936 | }, 1937 | "node_modules/side-channel": { 1938 | "version": "1.0.4", 1939 | "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", 1940 | "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", 1941 | "dependencies": { 1942 | "call-bind": "^1.0.0", 1943 | "get-intrinsic": "^1.0.2", 1944 | "object-inspect": "^1.9.0" 1945 | }, 1946 | "funding": { 1947 | "url": "https://github.com/sponsors/ljharb" 1948 | } 1949 | }, 1950 | "node_modules/sift": { 1951 | "version": "16.0.1", 1952 | "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz", 1953 | "integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==" 1954 | }, 1955 | "node_modules/signal-exit": { 1956 | "version": "3.0.7", 1957 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", 1958 | "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" 1959 | }, 1960 | "node_modules/simple-update-notifier": { 1961 | "version": "2.0.0", 1962 | "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", 1963 | "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", 1964 | "dev": true, 1965 | "dependencies": { 1966 | "semver": "^7.5.3" 1967 | }, 1968 | "engines": { 1969 | "node": ">=10" 1970 | } 1971 | }, 1972 | "node_modules/sparse-bitfield": { 1973 | "version": "3.0.3", 1974 | "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", 1975 | "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", 1976 | "dependencies": { 1977 | "memory-pager": "^1.0.2" 1978 | } 1979 | }, 1980 | "node_modules/statuses": { 1981 | "version": "2.0.1", 1982 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", 1983 | "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", 1984 | "engines": { 1985 | "node": ">= 0.8" 1986 | } 1987 | }, 1988 | "node_modules/streamsearch": { 1989 | "version": "1.1.0", 1990 | "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", 1991 | "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", 1992 | "engines": { 1993 | "node": ">=10.0.0" 1994 | } 1995 | }, 1996 | "node_modules/string_decoder": { 1997 | "version": "1.3.0", 1998 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", 1999 | "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", 2000 | "dependencies": { 2001 | "safe-buffer": "~5.2.0" 2002 | } 2003 | }, 2004 | "node_modules/string-width": { 2005 | "version": "4.2.3", 2006 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", 2007 | "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", 2008 | "dependencies": { 2009 | "emoji-regex": "^8.0.0", 2010 | "is-fullwidth-code-point": "^3.0.0", 2011 | "strip-ansi": "^6.0.1" 2012 | }, 2013 | "engines": { 2014 | "node": ">=8" 2015 | } 2016 | }, 2017 | "node_modules/strip-ansi": { 2018 | "version": "6.0.1", 2019 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", 2020 | "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", 2021 | "dependencies": { 2022 | "ansi-regex": "^5.0.1" 2023 | }, 2024 | "engines": { 2025 | "node": ">=8" 2026 | } 2027 | }, 2028 | "node_modules/supports-color": { 2029 | "version": "5.5.0", 2030 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 2031 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 2032 | "dev": true, 2033 | "dependencies": { 2034 | "has-flag": "^3.0.0" 2035 | }, 2036 | "engines": { 2037 | "node": ">=4" 2038 | } 2039 | }, 2040 | "node_modules/tar": { 2041 | "version": "6.2.0", 2042 | "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", 2043 | "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", 2044 | "dependencies": { 2045 | "chownr": "^2.0.0", 2046 | "fs-minipass": "^2.0.0", 2047 | "minipass": "^5.0.0", 2048 | "minizlib": "^2.1.1", 2049 | "mkdirp": "^1.0.3", 2050 | "yallist": "^4.0.0" 2051 | }, 2052 | "engines": { 2053 | "node": ">=10" 2054 | } 2055 | }, 2056 | "node_modules/to-regex-range": { 2057 | "version": "5.0.1", 2058 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 2059 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 2060 | "dev": true, 2061 | "dependencies": { 2062 | "is-number": "^7.0.0" 2063 | }, 2064 | "engines": { 2065 | "node": ">=8.0" 2066 | } 2067 | }, 2068 | "node_modules/toidentifier": { 2069 | "version": "1.0.1", 2070 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", 2071 | "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", 2072 | "engines": { 2073 | "node": ">=0.6" 2074 | } 2075 | }, 2076 | "node_modules/touch": { 2077 | "version": "3.1.0", 2078 | "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", 2079 | "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", 2080 | "dev": true, 2081 | "dependencies": { 2082 | "nopt": "~1.0.10" 2083 | }, 2084 | "bin": { 2085 | "nodetouch": "bin/nodetouch.js" 2086 | } 2087 | }, 2088 | "node_modules/tr46": { 2089 | "version": "3.0.0", 2090 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", 2091 | "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", 2092 | "dependencies": { 2093 | "punycode": "^2.1.1" 2094 | }, 2095 | "engines": { 2096 | "node": ">=12" 2097 | } 2098 | }, 2099 | "node_modules/type-is": { 2100 | "version": "1.6.18", 2101 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 2102 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", 2103 | "dependencies": { 2104 | "media-typer": "0.3.0", 2105 | "mime-types": "~2.1.24" 2106 | }, 2107 | "engines": { 2108 | "node": ">= 0.6" 2109 | } 2110 | }, 2111 | "node_modules/typedarray": { 2112 | "version": "0.0.6", 2113 | "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", 2114 | "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==" 2115 | }, 2116 | "node_modules/undefsafe": { 2117 | "version": "2.0.5", 2118 | "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", 2119 | "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", 2120 | "dev": true 2121 | }, 2122 | "node_modules/undici-types": { 2123 | "version": "5.26.5", 2124 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", 2125 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" 2126 | }, 2127 | "node_modules/unpipe": { 2128 | "version": "1.0.0", 2129 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 2130 | "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", 2131 | "engines": { 2132 | "node": ">= 0.8" 2133 | } 2134 | }, 2135 | "node_modules/util-deprecate": { 2136 | "version": "1.0.2", 2137 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 2138 | "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" 2139 | }, 2140 | "node_modules/utils-merge": { 2141 | "version": "1.0.1", 2142 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 2143 | "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", 2144 | "engines": { 2145 | "node": ">= 0.4.0" 2146 | } 2147 | }, 2148 | "node_modules/vary": { 2149 | "version": "1.1.2", 2150 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 2151 | "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", 2152 | "engines": { 2153 | "node": ">= 0.8" 2154 | } 2155 | }, 2156 | "node_modules/webidl-conversions": { 2157 | "version": "7.0.0", 2158 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", 2159 | "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", 2160 | "engines": { 2161 | "node": ">=12" 2162 | } 2163 | }, 2164 | "node_modules/whatwg-url": { 2165 | "version": "11.0.0", 2166 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", 2167 | "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", 2168 | "dependencies": { 2169 | "tr46": "^3.0.0", 2170 | "webidl-conversions": "^7.0.0" 2171 | }, 2172 | "engines": { 2173 | "node": ">=12" 2174 | } 2175 | }, 2176 | "node_modules/wide-align": { 2177 | "version": "1.1.5", 2178 | "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", 2179 | "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", 2180 | "dependencies": { 2181 | "string-width": "^1.0.2 || 2 || 3 || 4" 2182 | } 2183 | }, 2184 | "node_modules/wrappy": { 2185 | "version": "1.0.2", 2186 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 2187 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" 2188 | }, 2189 | "node_modules/xtend": { 2190 | "version": "4.0.2", 2191 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", 2192 | "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", 2193 | "engines": { 2194 | "node": ">=0.4" 2195 | } 2196 | }, 2197 | "node_modules/yallist": { 2198 | "version": "4.0.0", 2199 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 2200 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" 2201 | } 2202 | } 2203 | } 2204 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "coffee-backend", 3 | "version": "1.0.0", 4 | "description": "backend with coffee", 5 | "main": "index.js", 6 | "type": "module", 7 | "engines": { 8 | "node": "16.x" 9 | }, 10 | "scripts": { 11 | "dev": "nodemon -r dotenv/config --experimental-json-modules src/index.js", 12 | "start": "node src/index.js" 13 | }, 14 | "keywords": [ 15 | "javascript", 16 | "backend", 17 | "coffee" 18 | ], 19 | "author": "Hruthik", 20 | "license": "ISC", 21 | "devDependencies": { 22 | "nodemon": "^3.0.1", 23 | "prettier": "^3.0.3" 24 | }, 25 | "dependencies": { 26 | "bcrypt": "^5.1.1", 27 | "cloudinary": "^1.41.0", 28 | "cookie-parser": "^1.4.6", 29 | "cors": "^2.8.5", 30 | "dotenv": "^16.3.1", 31 | "express": "^4.18.2", 32 | "jsonwebtoken": "^9.0.2", 33 | "mongoose": "^8.0.0", 34 | "mongoose-aggregate-paginate-v2": "^1.0.6", 35 | "morgan": "^1.10.0", 36 | "multer": "^1.4.5-lts.1" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /public/temp/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hruthik-28/youtube-twitter/b62953456acc3236452b215500095e3f264a5047/public/temp/.gitkeep -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # YouTube + Twitter Backend 2 | 3 | ## Introduction 4 | 5 | This is a ``YOUTUBE + TWITTER`` backend project that covers allmost the functionalities of youtube 6 | and also combines the tweet functionality from twitter into it. Find more about his project in the documentaion below. 7 | 8 | ## Important links 9 | 10 | | Content | Link | 11 | | -------------------| ----------------------------------------------------------------------------| 12 | | API Documentation | [click here](https://documenter.getpostman.com/view/28570926/2s9YsNdVwW) | 13 | | Model | [click here ](https://app.eraser.io/workspace/YtPqZ1VogxGy1jzIDkzj) | 14 | 15 | ## Features 16 | 17 | ### User Management: 18 | 19 | - Registration, login, logout, password reset 20 | - Profile management (avatar, cover image, details) 21 | - Watch history tracking 22 | 23 | ### Video Management: 24 | 25 | - Video upload and publishing 26 | - Video search, sorting, and pagination 27 | - Video editing and deletion 28 | - Visibility control (publish/unpublish) 29 | 30 | ### Tweet Management: 31 | 32 | - Tweet creation and publishing 33 | - Viewing user tweets 34 | - Updating and deleting tweets 35 | 36 | ### Subscription Management: 37 | 38 | - Subscribing to channels 39 | - Viewing subscriber and subscribed channel lists 40 | 41 | ### Playlist Management: 42 | 43 | - Creating, updating, and deleting playlists 44 | - Adding and removing videos from playlists 45 | - Viewing user playlists 46 | 47 | ### Like Management: 48 | 49 | - Liking and unliking videos, comments, and tweets 50 | - Viewing liked videos 51 | 52 | ### Comment Management: 53 | 54 | - Adding, updating, and deleting comments on videos 55 | 56 | ### Dashboard: 57 | 58 | - Viewing channel statistics (views, subscribers, videos, likes) 59 | - Accessing uploaded videos 60 | 61 | ### Health Check: 62 | 63 | - Endpoint to verify the backend's health 64 | 65 | ## Technologies Used 66 | 67 | - Node.js 68 | - Express.js 69 | - MongoDB 70 | - Cloudinary (must have an account) 71 | 72 | ## Installation and Setup 73 | 74 | 1. **Clone the repository:** 75 | 76 | ```bash 77 | git clone https://github.com/Hruthik-28/youtube-twitter.git 78 | ``` 79 | 80 | 2. **Install dependencies:** 81 | 82 | ```bash 83 | cd youtube-twitter 84 | npm install 85 | ``` 86 | 87 | 3. **Set up environment variables:** 88 | Create a .env in root of project and fill in the required values in the .env file using .env.sample file 89 | 90 | 4. **Start the server:** 91 | 92 | ```bash 93 | npm run dev 94 | ``` 95 | 96 | ## Contributing 97 | 98 | If you wish to contribute to this project, please feel free to contribute. 99 | 100 | ## License 101 | 102 | This project is licensed under [ChaiAurCode](https://www.youtube.com/@chaiaurcode). 103 | -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | import cors from "cors"; 3 | import cookieParser from "cookie-parser"; 4 | import morgan from "morgan"; 5 | 6 | const app = new express(); 7 | 8 | app.use( 9 | cors({ 10 | origin: process.env.CORS_ORIGIN, 11 | credentials: true, 12 | }) 13 | ); 14 | 15 | app.use(express.json({ limit: "50mb" })); 16 | app.use(express.urlencoded({ extended: true, limit: "50mb" })); 17 | app.use(express.static("public")); 18 | app.use(cookieParser()); 19 | app.use(morgan("dev")); //HTTP request logger middleware for node.js 20 | 21 | 22 | 23 | //routes import 24 | 25 | import userRouter from "./routes/user.routes.js"; 26 | import commentRouter from "./routes/comment.routes.js"; 27 | import likeRouter from "./routes/like.routes.js"; 28 | import subscriptionRouter from "./routes/subscription.routes.js"; 29 | import tweetRouter from "./routes/tweet.routes.js"; 30 | import videoRouter from "./routes/video.routes.js"; 31 | import healthcheckRouter from "./routes/healthcheck.routes.js"; 32 | import playlistRouter from "./routes/playlist.routes.js"; 33 | import dashboardRouter from "./routes/dashboard.routes.js"; 34 | 35 | //routes declaration 36 | app.use("/api/v1/users", userRouter); 37 | app.use("/api/v1/comment", commentRouter); 38 | app.use("/api/v1/likes", likeRouter); 39 | app.use("/api/v1/subscriptions", subscriptionRouter); 40 | app.use("/api/v1/tweet", tweetRouter); 41 | app.use("/api/v1/video", videoRouter); 42 | app.use("/api/v1/healthcheck", healthcheckRouter); 43 | app.use("/api/v1/playlist", playlistRouter); 44 | app.use("/api/v1/dashboard", dashboardRouter); 45 | 46 | 47 | export default app; 48 | -------------------------------------------------------------------------------- /src/constants.js: -------------------------------------------------------------------------------- 1 | export const DB_NAME = 'silvertube' -------------------------------------------------------------------------------- /src/controllers/comment.controller.js: -------------------------------------------------------------------------------- 1 | import mongoose, { Schema } from "mongoose"; 2 | import { Comment } from "../models/comment.model.js"; 3 | import { Video } from "../models/video.model.js"; 4 | import { Like } from "../models/like.model.js"; 5 | import ApiError from "../utils/apiError.js"; 6 | import ApiResponse from "../utils/ApiResponse.js"; 7 | import asyncHandler from "../utils/asyncHandler.js"; 8 | 9 | // get all comments for a video 10 | const getVideoComments = asyncHandler(async (req, res) => { 11 | const { videoId } = req.params; 12 | const { page = 1, limit = 10 } = req.query; 13 | 14 | const video = await Video.findById(videoId); 15 | 16 | if (!video) { 17 | throw new ApiError(404, "Video not found"); 18 | } 19 | 20 | const commentsAggregate = Comment.aggregate([ 21 | { 22 | $match: { 23 | video: new mongoose.Types.ObjectId(videoId) 24 | } 25 | }, 26 | { 27 | $lookup: { 28 | from: "users", 29 | localField: "owner", 30 | foreignField: "_id", 31 | as: "owner" 32 | } 33 | }, 34 | { 35 | $lookup: { 36 | from: "likes", 37 | localField: "_id", 38 | foreignField: "comment", 39 | as: "likes" 40 | } 41 | }, 42 | { 43 | $addFields: { 44 | likesCount: { 45 | $size: "$likes" 46 | }, 47 | owner: { 48 | $first: "$owner" 49 | }, 50 | isLiked: { 51 | $cond: { 52 | if: { $in: [req.user?._id, "$likes.likedBy"] }, 53 | then: true, 54 | else: false 55 | } 56 | } 57 | } 58 | }, 59 | { 60 | $sort: { 61 | createdAt: -1 62 | } 63 | }, 64 | { 65 | $project: { 66 | content: 1, 67 | createdAt: 1, 68 | likesCount: 1, 69 | owner: { 70 | username: 1, 71 | fullName: 1, 72 | "avatar.url": 1 73 | }, 74 | isLiked: 1 75 | } 76 | } 77 | ]); 78 | 79 | const options = { 80 | page: parseInt(page, 10), 81 | limit: parseInt(limit, 10) 82 | }; 83 | 84 | const comments = await Comment.aggregatePaginate( 85 | commentsAggregate, 86 | options 87 | ); 88 | 89 | return res 90 | .status(200) 91 | .json(new ApiResponse(200, comments, "Comments fetched successfully")); 92 | }); 93 | 94 | // add a comment to a video 95 | const addComment = asyncHandler(async (req, res) => { 96 | const { videoId } = req.params; 97 | const { content } = req.body; 98 | 99 | if (!content) { 100 | throw new ApiError(400, "Content is required"); 101 | } 102 | 103 | const video = await Video.findById(videoId); 104 | 105 | if (!video) { 106 | throw new ApiError(404, "Video not found"); 107 | } 108 | 109 | const comment = await Comment.create({ 110 | content, 111 | video: videoId, 112 | owner: req.user?._id 113 | }); 114 | 115 | if (!comment) { 116 | throw new ApiError(500, "Failed to add comment please try again"); 117 | } 118 | 119 | return res 120 | .status(201) 121 | .json(new ApiResponse(201, comment, "Comment added successfully")); 122 | }); 123 | 124 | // update a comment 125 | const updateComment = asyncHandler(async (req, res) => { 126 | const { commentId } = req.params; 127 | const { content } = req.body; 128 | 129 | if (!content) { 130 | throw new ApiError(400, "content is required"); 131 | } 132 | 133 | const comment = await Comment.findById(commentId); 134 | 135 | if (!comment) { 136 | throw new ApiError(404, "Comment not found"); 137 | } 138 | 139 | if (comment?.owner.toString() !== req.user?._id.toString()) { 140 | throw new ApiError(400, "only comment owner can edit their comment"); 141 | } 142 | 143 | const updatedComment = await Comment.findByIdAndUpdate( 144 | comment?._id, 145 | { 146 | $set: { 147 | content 148 | } 149 | }, 150 | { new: true } 151 | ); 152 | 153 | if (!updatedComment) { 154 | throw new ApiError(500, "Failed to edit comment please try again"); 155 | } 156 | 157 | return res 158 | .status(200) 159 | .json( 160 | new ApiResponse(200, updatedComment, "Comment edited successfully") 161 | ); 162 | }); 163 | 164 | // delete a comment 165 | const deleteComment = asyncHandler(async (req, res) => { 166 | const { commentId } = req.params; 167 | 168 | const comment = await Comment.findById(commentId); 169 | 170 | if (!comment) { 171 | throw new ApiError(404, "Comment not found"); 172 | } 173 | 174 | if (comment?.owner.toString() !== req.user?._id.toString()) { 175 | throw new ApiError(400, "only comment owner can delete their comment"); 176 | } 177 | 178 | await Comment.findByIdAndDelete(commentId); 179 | 180 | await Like.deleteMany({ 181 | comment: commentId, 182 | likedBy: req.user 183 | }); 184 | 185 | return res 186 | .status(200) 187 | .json( 188 | new ApiResponse(200, { commentId }, "Comment deleted successfully") 189 | ); 190 | }); 191 | 192 | export { getVideoComments, addComment, updateComment, deleteComment }; 193 | -------------------------------------------------------------------------------- /src/controllers/dashboard.controller.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose"; 2 | import { Video } from "../models/video.model.js"; 3 | import { Subscription } from "../models/subscription.model.js"; 4 | import { Like } from "../models/like.model.js"; 5 | import ApiResponse from "../utils/ApiResponse.js"; 6 | import asyncHandler from "../utils/asyncHandler.js"; 7 | 8 | const getChannelStats = asyncHandler(async (req, res) => { 9 | // TODO: Get the channel stats like total video views, total subscribers, total videos, total likes etc. 10 | const userId = req.user?._id; 11 | 12 | const totalSubscribers = await Subscription.aggregate([ 13 | { 14 | $match: { 15 | channel: new mongoose.Types.ObjectId(userId) 16 | } 17 | }, 18 | { 19 | $group: { 20 | _id: null, 21 | subscribersCount: { 22 | $sum: 1 23 | } 24 | } 25 | } 26 | ]); 27 | 28 | const video = await Video.aggregate([ 29 | { 30 | $match: { 31 | owner: new mongoose.Types.ObjectId(userId) 32 | } 33 | }, 34 | { 35 | $lookup: { 36 | from: "likes", 37 | localField: "_id", 38 | foreignField: "video", 39 | as: "likes" 40 | } 41 | }, 42 | { 43 | $project: { 44 | totalLikes: { 45 | $size: "$likes" 46 | }, 47 | totalViews: "$views", 48 | totalVideos: 1 49 | } 50 | }, 51 | { 52 | $group: { 53 | _id: null, 54 | totalLikes: { 55 | $sum: "$totalLikes" 56 | }, 57 | totalViews: { 58 | $sum: "$totalViews" 59 | }, 60 | totalVideos: { 61 | $sum: 1 62 | } 63 | } 64 | } 65 | ]); 66 | 67 | const channelStats = { 68 | totalSubscribers: totalSubscribers[0]?.subscribersCount || 0, 69 | totalLikes: video[0]?.totalLikes || 0, 70 | totalViews: video[0]?.totalViews || 0, 71 | totalVideos: video[0]?.totalVideos || 0 72 | }; 73 | 74 | return res 75 | .status(200) 76 | .json( 77 | new ApiResponse( 78 | 200, 79 | channelStats, 80 | "channel stats fetched successfully" 81 | ) 82 | ); 83 | }); 84 | 85 | const getChannelVideos = asyncHandler(async (req, res) => { 86 | // TODO: Get all the videos uploaded by the channel 87 | const userId = req.user?._id; 88 | 89 | const videos = await Video.aggregate([ 90 | { 91 | $match: { 92 | owner: new mongoose.Types.ObjectId(userId) 93 | } 94 | }, 95 | { 96 | $lookup: { 97 | from: "likes", 98 | localField: "_id", 99 | foreignField: "video", 100 | as: "likes" 101 | } 102 | }, 103 | { 104 | $addFields: { 105 | createdAt: { 106 | $dateToParts: { date: "$createdAt" } 107 | }, 108 | likesCount: { 109 | $size: "$likes" 110 | } 111 | } 112 | }, 113 | { 114 | $sort: { 115 | createdAt: -1 116 | } 117 | }, 118 | { 119 | $project: { 120 | _id: 1, 121 | "videoFile.url": 1, 122 | "thumbnail.url": 1, 123 | title: 1, 124 | description: 1, 125 | createdAt: { 126 | year: 1, 127 | month: 1, 128 | day: 1 129 | }, 130 | isPublished: 1, 131 | likesCount: 1 132 | } 133 | } 134 | ]); 135 | 136 | return res 137 | .status(200) 138 | .json( 139 | new ApiResponse( 140 | 200, 141 | videos, 142 | "channel stats fetched successfully" 143 | ) 144 | ); 145 | }); 146 | 147 | export { getChannelStats, getChannelVideos }; 148 | -------------------------------------------------------------------------------- /src/controllers/healthcheck.controller.js: -------------------------------------------------------------------------------- 1 | import asyncHandler from "../utils/asyncHandler.js"; 2 | import ApiError from "../utils/apiError.js"; 3 | import { Tweet } from "../models/tweet.model.js"; 4 | import ApiResponse from "../utils/ApiResponse.js"; 5 | import mongoose, { isValidObjectId } from "mongoose"; 6 | import { User } from "../models/user.model.js"; 7 | 8 | const healthcheck = asyncHandler(async (req, res) => { 9 | return res 10 | .status(200) 11 | .json(new ApiResponse(200, { message: "Everything is O.K" }, "Ok")); 12 | }); 13 | 14 | export { healthcheck }; 15 | -------------------------------------------------------------------------------- /src/controllers/like.controller.js: -------------------------------------------------------------------------------- 1 | import mongoose, { isValidObjectId } from "mongoose"; 2 | import { Like } from "../models/like.model.js"; 3 | import ApiResponse from "../utils/ApiResponse.js"; 4 | import ApiError from "../utils/apiError.js"; 5 | import asyncHandler from "../utils/asyncHandler.js"; 6 | 7 | const toggleVideoLike = asyncHandler(async (req, res) => { 8 | const { videoId } = req.params; 9 | 10 | if (!isValidObjectId(videoId)) { 11 | throw new ApiError(400, "Invalid videoId"); 12 | } 13 | 14 | 15 | const likedAlready = await Like.findOne({ 16 | video: videoId, 17 | likedBy: req.user?._id, 18 | }); 19 | 20 | if (likedAlready) { 21 | await Like.findByIdAndDelete(likedAlready?._id); 22 | 23 | return res 24 | .status(200) 25 | .json(new ApiResponse(200, { isLiked: false })); 26 | } 27 | 28 | await Like.create({ 29 | video: videoId, 30 | likedBy: req.user?._id, 31 | }); 32 | 33 | return res 34 | .status(200) 35 | .json(new ApiResponse(200, { isLiked: true })); 36 | }); 37 | 38 | const toggleCommentLike = asyncHandler(async (req, res) => { 39 | const { commentId } = req.params; 40 | 41 | if (!isValidObjectId(commentId)) { 42 | throw new ApiError(400, "Invalid commentId"); 43 | } 44 | 45 | 46 | const likedAlready = await Like.findOne({ 47 | comment: commentId, 48 | likedBy: req.user?._id, 49 | }); 50 | 51 | if (likedAlready) { 52 | await Like.findByIdAndDelete(likedAlready?._id); 53 | 54 | return res 55 | .status(200) 56 | .json(new ApiResponse(200, { isLiked: false })); 57 | } 58 | 59 | await Like.create({ 60 | comment: commentId, 61 | likedBy: req.user?._id, 62 | }); 63 | 64 | return res 65 | .status(200) 66 | .json(new ApiResponse(200, { isLiked: true })); 67 | }); 68 | 69 | const toggleTweetLike = asyncHandler(async (req, res) => { 70 | const { tweetId } = req.params; 71 | 72 | if (!isValidObjectId(tweetId)) { 73 | throw new ApiError(400, "Invalid tweetId"); 74 | } 75 | 76 | 77 | const likedAlready = await Like.findOne({ 78 | tweet: tweetId, 79 | likedBy: req.user?._id, 80 | }); 81 | 82 | if (likedAlready) { 83 | await Like.findByIdAndDelete(likedAlready?._id); 84 | 85 | return res 86 | .status(200) 87 | .json(new ApiResponse(200, { tweetId, isLiked: false })); 88 | } 89 | 90 | await Like.create({ 91 | tweet: tweetId, 92 | likedBy: req.user?._id, 93 | }); 94 | 95 | return res 96 | .status(200) 97 | .json(new ApiResponse(200, { isLiked: true })); 98 | }); 99 | 100 | const getLikedVideos = asyncHandler(async (req, res) => { 101 | const likedVideosAggegate = await Like.aggregate([ 102 | { 103 | $match: { 104 | likedBy: new mongoose.Types.ObjectId(req.user?._id), 105 | }, 106 | }, 107 | { 108 | $lookup: { 109 | from: "videos", 110 | localField: "video", 111 | foreignField: "_id", 112 | as: "likedVideo", 113 | pipeline: [ 114 | { 115 | $lookup: { 116 | from: "users", 117 | localField: "owner", 118 | foreignField: "_id", 119 | as: "ownerDetails", 120 | }, 121 | }, 122 | { 123 | $unwind: "$ownerDetails", 124 | }, 125 | ], 126 | }, 127 | }, 128 | { 129 | $unwind: "$likedVideo", 130 | }, 131 | { 132 | $sort: { 133 | createdAt: -1, 134 | }, 135 | }, 136 | { 137 | $project: { 138 | _id: 0, 139 | likedVideo: { 140 | _id: 1, 141 | "videoFile.url": 1, 142 | "thumbnail.url": 1, 143 | owner: 1, 144 | title: 1, 145 | description: 1, 146 | views: 1, 147 | duration: 1, 148 | createdAt: 1, 149 | isPublished: 1, 150 | ownerDetails: { 151 | username: 1, 152 | fullName: 1, 153 | "avatar.url": 1, 154 | }, 155 | }, 156 | }, 157 | }, 158 | ]); 159 | 160 | return res 161 | .status(200) 162 | .json( 163 | new ApiResponse( 164 | 200, 165 | likedVideosAggegate, 166 | "liked videos fetched successfully" 167 | ) 168 | ); 169 | }); 170 | 171 | export { toggleVideoLike, toggleCommentLike, toggleTweetLike, getLikedVideos }; 172 | -------------------------------------------------------------------------------- /src/controllers/playlist.controller.js: -------------------------------------------------------------------------------- 1 | import { Playlist } from "../models/playlist.model.js"; 2 | import { Video } from "../models/video.model.js"; 3 | import ApiResponse from "../utils/ApiResponse.js"; 4 | import ApiError from "../utils/apiError.js"; 5 | import asyncHandler from "../utils/asyncHandler.js"; 6 | import mongoose, { isValidObjectId } from "mongoose"; 7 | 8 | const createPlaylist = asyncHandler(async (req, res) => { 9 | const { name, description } = req.body; 10 | 11 | if (!name || !description) { 12 | throw new ApiError(400, "name and description both are required"); 13 | } 14 | 15 | const playlist = await Playlist.create({ 16 | name, 17 | description, 18 | owner: req.user?._id, 19 | }); 20 | 21 | if (!playlist) { 22 | throw new ApiError(500, "failed to create playlist"); 23 | } 24 | 25 | return res 26 | .status(200) 27 | .json(new ApiResponse(200, playlist, "playlist created successfully")); 28 | }); 29 | 30 | const updatePlaylist = asyncHandler(async (req, res) => { 31 | const { name, description } = req.body; 32 | const { playlistId } = req.params; 33 | 34 | if (!name || !description) { 35 | throw new ApiError(400, "name and description both are required"); 36 | } 37 | 38 | if (!isValidObjectId(playlistId)) { 39 | throw new ApiError(400, "Invalid PlaylistId"); 40 | } 41 | 42 | const playlist = await Playlist.findById(playlistId); 43 | 44 | if (!playlist) { 45 | throw new ApiError(404, "Playlist not found"); 46 | } 47 | 48 | if (playlist.owner.toString() !== req.user?._id.toString()) { 49 | throw new ApiError(400, "only owner can edit the playlist"); 50 | } 51 | 52 | const updatedPlaylist = await Playlist.findByIdAndUpdate( 53 | playlist?._id, 54 | { 55 | $set: { 56 | name, 57 | description, 58 | }, 59 | }, 60 | { new: true } 61 | ); 62 | 63 | return res 64 | .status(200) 65 | .json( 66 | new ApiResponse( 67 | 200, 68 | updatedPlaylist, 69 | "playlist updated successfully" 70 | ) 71 | ); 72 | }); 73 | 74 | const deletePlaylist = asyncHandler(async (req, res) => { 75 | const { playlistId } = req.params; 76 | 77 | if (!isValidObjectId(playlistId)) { 78 | throw new ApiError(400, "Invalid PlaylistId"); 79 | } 80 | 81 | const playlist = await Playlist.findById(playlistId); 82 | 83 | if (!playlist) { 84 | throw new ApiError(404, "Playlist not found"); 85 | } 86 | 87 | if (playlist.owner.toString() !== req.user?._id.toString()) { 88 | throw new ApiError(400, "only owner can delete the playlist"); 89 | } 90 | 91 | await Playlist.findByIdAndDelete(playlist?._id); 92 | 93 | return res 94 | .status(200) 95 | .json( 96 | new ApiResponse( 97 | 200, 98 | {}, 99 | "playlist updated successfully" 100 | ) 101 | ); 102 | }); 103 | 104 | const addVideoToPlaylist = asyncHandler(async (req, res) => { 105 | const { playlistId, videoId } = req.params; 106 | 107 | if (!isValidObjectId(playlistId) || !isValidObjectId(videoId)) { 108 | throw new ApiError(400, "Invalid PlaylistId or videoId"); 109 | } 110 | 111 | const playlist = await Playlist.findById(playlistId); 112 | const video = await Video.findById(videoId); 113 | 114 | if (!playlist) { 115 | throw new ApiError(404, "Playlist not found"); 116 | } 117 | if (!video) { 118 | throw new ApiError(404, "video not found"); 119 | } 120 | 121 | if ( 122 | (playlist.owner?.toString() && video.owner.toString()) !== 123 | req.user?._id.toString() 124 | ) { 125 | throw new ApiError(400, "only owner can add video to thier playlist"); 126 | } 127 | 128 | const updatedPlaylist = await Playlist.findByIdAndUpdate( 129 | playlist?._id, 130 | { 131 | $addToSet: { 132 | videos: videoId, 133 | }, 134 | }, 135 | { new: true } 136 | ); 137 | 138 | if (!updatedPlaylist) { 139 | throw new ApiError( 140 | 400, 141 | "failed to add video to playlist please try again" 142 | ); 143 | } 144 | 145 | return res 146 | .status(200) 147 | .json( 148 | new ApiResponse( 149 | 200, 150 | updatedPlaylist, 151 | "Added video to playlist successfully" 152 | ) 153 | ); 154 | }); 155 | 156 | const removeVideoFromPlaylist = asyncHandler(async (req, res) => { 157 | const { playlistId, videoId } = req.params; 158 | 159 | if (!isValidObjectId(playlistId) || !isValidObjectId(videoId)) { 160 | throw new ApiError(400, "Invalid PlaylistId or videoId"); 161 | } 162 | 163 | const playlist = await Playlist.findById(playlistId); 164 | const video = await Video.findById(videoId); 165 | 166 | if (!playlist) { 167 | throw new ApiError(404, "Playlist not found"); 168 | } 169 | if (!video) { 170 | throw new ApiError(404, "video not found"); 171 | } 172 | 173 | if ( 174 | (playlist.owner?.toString() && video.owner.toString()) !== 175 | req.user?._id.toString() 176 | ) { 177 | throw new ApiError( 178 | 404, 179 | "only owner can remove video from thier playlist" 180 | ); 181 | } 182 | 183 | const updatedPlaylist = await Playlist.findByIdAndUpdate( 184 | playlistId, 185 | { 186 | $pull: { 187 | videos: videoId, 188 | }, 189 | }, 190 | { new: true } 191 | ); 192 | 193 | return res 194 | .status(200) 195 | .json( 196 | new ApiResponse( 197 | 200, 198 | updatedPlaylist, 199 | "Removed video from playlist successfully" 200 | ) 201 | ); 202 | }); 203 | 204 | const getPlaylistById = asyncHandler(async (req, res) => { 205 | const { playlistId } = req.params; 206 | 207 | if (!isValidObjectId(playlistId)) { 208 | throw new ApiError(400, "Invalid PlaylistId"); 209 | } 210 | 211 | const playlist = await Playlist.findById(playlistId); 212 | 213 | if (!playlist) { 214 | throw new ApiError(404, "Playlist not found"); 215 | } 216 | 217 | const playlistVideos = await Playlist.aggregate([ 218 | { 219 | $match: { 220 | _id: new mongoose.Types.ObjectId(playlistId) 221 | } 222 | }, 223 | { 224 | $lookup: { 225 | from: "videos", 226 | localField: "videos", 227 | foreignField: "_id", 228 | as: "videos", 229 | } 230 | }, 231 | { 232 | $match: { 233 | "videos.isPublished": true 234 | } 235 | }, 236 | { 237 | $lookup: { 238 | from: "users", 239 | localField: "owner", 240 | foreignField: "_id", 241 | as: "owner", 242 | } 243 | }, 244 | { 245 | $addFields: { 246 | totalVideos: { 247 | $size: "$videos" 248 | }, 249 | totalViews: { 250 | $sum: "$videos.views" 251 | }, 252 | owner: { 253 | $first: "$owner" 254 | } 255 | } 256 | }, 257 | { 258 | $project: { 259 | name: 1, 260 | description: 1, 261 | createdAt: 1, 262 | updatedAt: 1, 263 | totalVideos: 1, 264 | totalViews: 1, 265 | videos: { 266 | _id: 1, 267 | "videoFile.url": 1, 268 | "thumbnail.url": 1, 269 | title: 1, 270 | description: 1, 271 | duration: 1, 272 | createdAt: 1, 273 | views: 1 274 | }, 275 | owner: { 276 | username: 1, 277 | fullName: 1, 278 | "avatar.url": 1 279 | } 280 | } 281 | } 282 | 283 | ]); 284 | 285 | return res 286 | .status(200) 287 | .json(new ApiResponse(200, playlistVideos[0], "playlist fetched successfully")); 288 | }); 289 | 290 | const getUserPlaylists = asyncHandler(async (req, res) => { 291 | const { userId } = req.params; 292 | 293 | if (!isValidObjectId(userId)) { 294 | throw new ApiError(400, "Invalid userId"); 295 | } 296 | 297 | const playlists = await Playlist.aggregate([ 298 | { 299 | $match: { 300 | owner: new mongoose.Types.ObjectId(userId) 301 | } 302 | }, 303 | { 304 | $lookup: { 305 | from: "videos", 306 | localField: "videos", 307 | foreignField: "_id", 308 | as: "videos" 309 | } 310 | }, 311 | { 312 | $addFields: { 313 | totalVideos: { 314 | $size: "$videos" 315 | }, 316 | totalViews: { 317 | $sum: "$videos.views" 318 | } 319 | } 320 | }, 321 | { 322 | $project: { 323 | _id: 1, 324 | name: 1, 325 | description: 1, 326 | totalVideos: 1, 327 | totalViews: 1, 328 | updatedAt: 1 329 | } 330 | } 331 | ]); 332 | 333 | return res 334 | .status(200) 335 | .json(new ApiResponse(200, playlists, "User playlists fetched successfully")); 336 | 337 | }); 338 | 339 | export { 340 | createPlaylist, 341 | updatePlaylist, 342 | deletePlaylist, 343 | addVideoToPlaylist, 344 | removeVideoFromPlaylist, 345 | getPlaylistById, 346 | getUserPlaylists, 347 | }; 348 | -------------------------------------------------------------------------------- /src/controllers/subscription.controller.js: -------------------------------------------------------------------------------- 1 | import mongoose, { isValidObjectId } from "mongoose"; 2 | import asyncHandler from "../utils/asyncHandler.js"; 3 | import ApiError from "../utils/apiError.js"; 4 | import ApiResponse from "../utils/ApiResponse.js"; 5 | import { Subscription } from "../models/subscription.model.js"; 6 | 7 | const toggleSubscription = asyncHandler(async (req, res) => { 8 | const { channelId } = req.params; 9 | // TODO: toggle subscription 10 | 11 | if (!isValidObjectId(channelId)) { 12 | throw new ApiError(400, "Invalid channelId"); 13 | } 14 | 15 | const isSubscribed = await Subscription.findOne({ 16 | subscriber: req.user?._id, 17 | channel: channelId, 18 | }); 19 | 20 | if (isSubscribed) { 21 | await Subscription.findByIdAndDelete(isSubscribed?._id); 22 | 23 | return res 24 | .status(200) 25 | .json( 26 | new ApiResponse( 27 | 200, 28 | { subscribed: false }, 29 | "unsunscribed successfully" 30 | ) 31 | ); 32 | } 33 | 34 | await Subscription.create({ 35 | subscriber: req.user?._id, 36 | channel: channelId, 37 | }); 38 | 39 | return res 40 | .status(200) 41 | .json( 42 | new ApiResponse( 43 | 200, 44 | { subscribed: true }, 45 | "subscribed successfully" 46 | ) 47 | ); 48 | }); 49 | 50 | // controller to return subscriber list of a channel 51 | const getUserChannelSubscribers = asyncHandler(async (req, res) => { 52 | let { channelId } = req.params; 53 | 54 | if (!isValidObjectId(channelId)) { 55 | throw new ApiError(400, "Invalid channelId"); 56 | } 57 | 58 | channelId = new mongoose.Types.ObjectId(channelId); 59 | 60 | const subscribers = await Subscription.aggregate([ 61 | { 62 | $match: { 63 | channel: channelId, 64 | }, 65 | }, 66 | { 67 | $lookup: { 68 | from: "users", 69 | localField: "subscriber", 70 | foreignField: "_id", 71 | as: "subscriber", 72 | pipeline: [ 73 | { 74 | $lookup: { 75 | from: "subscriptions", 76 | localField: "_id", 77 | foreignField: "channel", 78 | as: "subscribedToSubscriber", 79 | }, 80 | }, 81 | { 82 | $addFields: { 83 | subscribedToSubscriber: { 84 | $cond: { 85 | if: { 86 | $in: [ 87 | channelId, 88 | "$subscribedToSubscriber.subscriber", 89 | ], 90 | }, 91 | then: true, 92 | else: false, 93 | }, 94 | }, 95 | subscribersCount: { 96 | $size: "$subscribedToSubscriber", 97 | }, 98 | }, 99 | }, 100 | ], 101 | }, 102 | }, 103 | { 104 | $unwind: "$subscriber", 105 | }, 106 | { 107 | $project: { 108 | _id: 0, 109 | subscriber: { 110 | _id: 1, 111 | username: 1, 112 | fullName: 1, 113 | "avatar.url": 1, 114 | subscribedToSubscriber: 1, 115 | subscribersCount: 1, 116 | }, 117 | }, 118 | }, 119 | ]); 120 | 121 | return res 122 | .status(200) 123 | .json( 124 | new ApiResponse( 125 | 200, 126 | subscribers, 127 | "subscribers fetched successfully" 128 | ) 129 | ); 130 | }); 131 | 132 | // controller to return channel list to which user has subscribed 133 | const getSubscribedChannels = asyncHandler(async (req, res) => { 134 | const { subscriberId } = req.params; 135 | 136 | const subscribedChannels = await Subscription.aggregate([ 137 | { 138 | $match: { 139 | subscriber: new mongoose.Types.ObjectId(subscriberId), 140 | }, 141 | }, 142 | { 143 | $lookup: { 144 | from: "users", 145 | localField: "channel", 146 | foreignField: "_id", 147 | as: "subscribedChannel", 148 | pipeline: [ 149 | { 150 | $lookup: { 151 | from: "videos", 152 | localField: "_id", 153 | foreignField: "owner", 154 | as: "videos", 155 | }, 156 | }, 157 | { 158 | $addFields: { 159 | latestVideo: { 160 | $last: "$videos", 161 | }, 162 | }, 163 | }, 164 | ], 165 | }, 166 | }, 167 | { 168 | $unwind: "$subscribedChannel", 169 | }, 170 | { 171 | $project: { 172 | _id: 0, 173 | subscribedChannel: { 174 | _id: 1, 175 | username: 1, 176 | fullName: 1, 177 | "avatar.url": 1, 178 | latestVideo: { 179 | _id: 1, 180 | "videoFile.url": 1, 181 | "thumbnail.url": 1, 182 | owner: 1, 183 | title: 1, 184 | description: 1, 185 | duration: 1, 186 | createdAt: 1, 187 | views: 1 188 | }, 189 | }, 190 | }, 191 | }, 192 | ]); 193 | 194 | return res 195 | .status(200) 196 | .json( 197 | new ApiResponse( 198 | 200, 199 | subscribedChannels, 200 | "subscribed channels fetched successfully" 201 | ) 202 | ); 203 | }); 204 | 205 | export { toggleSubscription, getUserChannelSubscribers, getSubscribedChannels }; 206 | -------------------------------------------------------------------------------- /src/controllers/tweet.controller.js: -------------------------------------------------------------------------------- 1 | import asyncHandler from "../utils/asyncHandler.js"; 2 | import ApiError from "../utils/apiError.js"; 3 | import { Tweet } from "../models/tweet.model.js"; 4 | import ApiResponse from "../utils/ApiResponse.js"; 5 | import mongoose, { isValidObjectId } from "mongoose"; 6 | import { User } from "../models/user.model.js"; 7 | 8 | const createTweet = asyncHandler(async (req, res) => { 9 | const { content } = req.body; 10 | 11 | if (!content) { 12 | throw new ApiError(400, "content is required"); 13 | } 14 | 15 | const tweet = await Tweet.create({ 16 | content, 17 | owner: req.user?._id, 18 | }); 19 | 20 | if (!tweet) { 21 | throw new ApiError(500, "failed to create tweet please try again"); 22 | } 23 | 24 | return res 25 | .status(200) 26 | .json(new ApiResponse(200, tweet, "Tweet created successfully")); 27 | }); 28 | 29 | const updateTweet = asyncHandler(async (req, res) => { 30 | const { content } = req.body; 31 | const { tweetId } = req.params; 32 | 33 | if (!content) { 34 | throw new ApiError(400, "content is required"); 35 | } 36 | 37 | if (!isValidObjectId(tweetId)) { 38 | throw new ApiError(400, "Invalid tweetId"); 39 | } 40 | 41 | const tweet = await Tweet.findById(tweetId); 42 | 43 | if (!tweet) { 44 | throw new ApiError(404, "Tweet not found"); 45 | } 46 | 47 | if (tweet?.owner.toString() !== req.user?._id.toString()) { 48 | throw new ApiError(400, "only owner can edit thier tweet"); 49 | } 50 | 51 | const newTweet = await Tweet.findByIdAndUpdate( 52 | tweetId, 53 | { 54 | $set: { 55 | content, 56 | }, 57 | }, 58 | { new: true } 59 | ); 60 | 61 | if (!newTweet) { 62 | throw new ApiError(500, "Failed to edit tweet please try again"); 63 | } 64 | 65 | return res 66 | .status(200) 67 | .json(new ApiResponse(200, newTweet, "Tweet updated successfully")); 68 | }); 69 | 70 | const deleteTweet = asyncHandler(async (req, res) => { 71 | const { tweetId } = req.params; 72 | 73 | if (!isValidObjectId(tweetId)) { 74 | throw new ApiError(400, "Invalid tweetId"); 75 | } 76 | 77 | const tweet = await Tweet.findById(tweetId); 78 | 79 | if (!tweet) { 80 | throw new ApiError(404, "Tweet not found"); 81 | } 82 | 83 | if (tweet?.owner.toString() !== req.user?._id.toString()) { 84 | throw new ApiError(400, "only owner can delete thier tweet"); 85 | } 86 | 87 | await Tweet.findByIdAndDelete(tweetId); 88 | 89 | return res 90 | .status(200) 91 | .json(new ApiResponse(200, {tweetId}, "Tweet deleted successfully")); 92 | }); 93 | 94 | const getUserTweets = asyncHandler(async (req, res) => { 95 | const { userId } = req.params; 96 | 97 | if (!isValidObjectId(userId)) { 98 | throw new ApiError(400, "Invalid userId"); 99 | } 100 | 101 | const tweets = await Tweet.aggregate([ 102 | { 103 | $match: { 104 | owner: new mongoose.Types.ObjectId(userId), 105 | }, 106 | }, 107 | { 108 | $lookup: { 109 | from: "users", 110 | localField: "owner", 111 | foreignField: "_id", 112 | as: "ownerDetails", 113 | pipeline: [ 114 | { 115 | $project: { 116 | username: 1, 117 | "avatar.url": 1, 118 | }, 119 | }, 120 | ], 121 | }, 122 | }, 123 | { 124 | $lookup: { 125 | from: "likes", 126 | localField: "_id", 127 | foreignField: "tweet", 128 | as: "likeDetails", 129 | pipeline: [ 130 | { 131 | $project: { 132 | likedBy: 1, 133 | }, 134 | }, 135 | ], 136 | }, 137 | }, 138 | { 139 | $addFields: { 140 | likesCount: { 141 | $size: "$likeDetails", 142 | }, 143 | ownerDetails: { 144 | $first: "$ownerDetails", 145 | }, 146 | isLiked: { 147 | $cond: { 148 | if: {$in: [req.user?._id, "$likeDetails.likedBy"]}, 149 | then: true, 150 | else: false 151 | } 152 | } 153 | }, 154 | }, 155 | { 156 | $sort: { 157 | createdAt: -1 158 | } 159 | }, 160 | { 161 | $project: { 162 | content: 1, 163 | ownerDetails: 1, 164 | likesCount: 1, 165 | createdAt: 1, 166 | isLiked: 1 167 | }, 168 | }, 169 | ]); 170 | 171 | return res 172 | .status(200) 173 | .json(new ApiResponse(200, tweets, "Tweets fetched successfully")); 174 | }); 175 | 176 | export { createTweet, updateTweet, deleteTweet, getUserTweets }; 177 | -------------------------------------------------------------------------------- /src/controllers/user.controller.js: -------------------------------------------------------------------------------- 1 | import asyncHandler from "../utils/asyncHandler.js" 2 | import ApiError from "../utils/apiError.js" 3 | import { User } from "../models/user.model.js" 4 | import {uploadOnCloudinary, deleteOnCloudinary} from "../utils/cloudinary.js" 5 | import ApiResponse from "../utils/ApiResponse.js" 6 | import JWT from "jsonwebtoken" 7 | import mongoose from 'mongoose' 8 | 9 | const generateAccessAndRefreshToken = async(userId) => { 10 | 11 | try { 12 | const user = await User.findById(userId); 13 | 14 | const accessToken = user.generateAccessToken(); 15 | const refreshToken = user.generateRefreshToken(); 16 | 17 | user.refreshToken = refreshToken; 18 | await user.save({ validateBeforeSave: false }); 19 | 20 | return { accessToken, refreshToken }; 21 | } catch (error) { 22 | throw new ApiError(500, "Something went wrong while generating refresh and access token."); 23 | } 24 | }; 25 | 26 | const registerUser = asyncHandler( async(req, res) => { 27 | // get user details from frontend 28 | // validation - not empty etc... 29 | // check if user already exists: username, email 30 | // check for images, avatar 31 | // upload to cloudinary, avatar check 32 | // create user object - create entry in db 33 | // remove password and refresh token from response 34 | // check for user creation 35 | // return response 36 | 37 | const {username, email, fullName, password} = req.body 38 | 39 | if ([username, email, fullName, password].some( 40 | (field) => ( field?.trim() === "" ) 41 | )) { 42 | throw new ApiError(400, "All fields are required") 43 | } 44 | 45 | const userExists = await User.findOne({ 46 | $or: [{ username }, { email }] 47 | }) 48 | 49 | if (userExists) throw new ApiError(409, "user with username or email already exists") 50 | 51 | // console.log("req.files", req.files); 52 | 53 | const avatarLocalPath = req.files?.avatar[0]?.path 54 | // console.log("avatarLocalPath", avatarLocalPath); 55 | 56 | let coverImageLocalPath; 57 | if (req.files && Array.isArray(req.files.coverImage) && req.files.coverImage.length > 0) { 58 | coverImageLocalPath = req.files.coverImage[0].path 59 | } 60 | 61 | if (!avatarLocalPath) throw new ApiError(400, "Avatar file is required") 62 | 63 | const avatar = await uploadOnCloudinary(avatarLocalPath).catch((error) => console.log(error)) 64 | const coverImage = await uploadOnCloudinary(coverImageLocalPath) 65 | 66 | // console.log(avatar);null 67 | if (!avatar) throw new ApiError(400, "Avatar file is required!!!.") 68 | 69 | const user = await User.create({ 70 | fullName, 71 | avatar: { 72 | public_id: avatar.public_id, 73 | url: avatar.secure_url 74 | }, 75 | coverImage: { 76 | public_id: coverImage?.public_id || "", 77 | url: coverImage?.secure_url || "" 78 | }, 79 | username: username.toLowerCase(), 80 | email, 81 | password 82 | }) 83 | 84 | const createdUser = await User.findById(user._id).select( 85 | "-password -refreshToken" 86 | ) 87 | 88 | if (!createdUser) throw new ApiError(500, "user registration failed, please try again") 89 | 90 | return res.status(201).json( 91 | new ApiResponse(200, createdUser, "user registered successfully") 92 | ) 93 | 94 | }); 95 | 96 | const loginUser = asyncHandler(async(req, res) => { 97 | // req body -> data 98 | // username or email 99 | // find the user 100 | // password check 101 | // access and refresh token 102 | // send tokens in cookies 103 | 104 | const {email, username, password} = req.body; 105 | 106 | if (!(username || email)) { 107 | throw new ApiError(400, "username or email is required."); 108 | } 109 | 110 | const user = await User.findOne({ 111 | $or: [{ email }, { username }] 112 | }); 113 | 114 | if (!user) { 115 | throw new ApiError(404, "User doesnot exist."); 116 | } 117 | 118 | const isPasswordCorrect = await user.comparePassword(password); 119 | 120 | if (!isPasswordCorrect) { 121 | throw new ApiError(401, "Invalid user credentials."); 122 | } 123 | 124 | const { accessToken, refreshToken } = await generateAccessAndRefreshToken(user._id); 125 | 126 | const loggedInUser = await User.findById(user._id).select(" -password -refreshToken"); 127 | 128 | const options = { 129 | httpOnly: true, 130 | secure: true, 131 | sameSite: "None" 132 | }; 133 | 134 | return res 135 | .status(200) 136 | .cookie("accessToken", accessToken, options) 137 | .cookie("refreshToken", refreshToken, options) 138 | .json( 139 | new ApiResponse( 140 | 200, 141 | { 142 | user: loggedInUser, accessToken, refreshToken 143 | }, 144 | "User logged in successfully !!!." 145 | ) 146 | ); 147 | 148 | }); 149 | 150 | const logoutUser = asyncHandler(async(req, res) => { 151 | await User.findByIdAndUpdate( 152 | req.user._id, 153 | { 154 | $unset: { 155 | refreshToken: 1 // removes field from document 156 | } 157 | }, 158 | { new: true } 159 | ); 160 | 161 | const options = { 162 | httpOnly: true, 163 | secure: true, 164 | sameSite: "None" 165 | }; 166 | 167 | return res 168 | .status(200) 169 | .clearCookie("accessToken", options) 170 | .clearCookie("refreshToken", options) 171 | .json( 172 | new ApiResponse( 173 | 200, 174 | {}, 175 | "User logout successfull !!!." 176 | ) 177 | ); 178 | }); 179 | 180 | const refreshAccessToken = asyncHandler(async(req, res) => { 181 | const incomingRefreshToken = req.cookies?.refreshToken || req.body.refreshToken; 182 | 183 | if (!incomingRefreshToken) { 184 | throw new ApiError(401, "unauthorized request"); 185 | } 186 | 187 | const user = await User.findOne({ 188 | refreshToken: incomingRefreshToken 189 | }); 190 | 191 | if (!user) { 192 | throw new ApiError(401, "Invalid refresh token"); 193 | } 194 | 195 | const { accessToken , refreshToken } = await generateAccessAndRefreshToken(user._id); 196 | 197 | const options = { 198 | httpOnly: true, 199 | secure: true, 200 | sameSite: "None" 201 | }; 202 | 203 | return res 204 | .status(200) 205 | .cookie("accessToken", accessToken, options) 206 | .cookie("refreshToken", refreshToken, options) 207 | .json( 208 | new ApiResponse( 209 | 200, 210 | { 211 | accessToken, 212 | refreshToken 213 | }, 214 | "Access token refreshed" 215 | ) 216 | ) 217 | 218 | }); 219 | 220 | const changeCurrentPassword = asyncHandler(async(req, res) => { 221 | const { oldPassword, newPassword } = req.body; 222 | 223 | const user = await User.findById(req.user?._id); 224 | 225 | const isOldPasswordCorrect = await user.comparePassword(oldPassword); 226 | 227 | if (!isOldPasswordCorrect) { 228 | throw new ApiError(400, "Incorrect old password"); 229 | } 230 | 231 | user.password = newPassword; 232 | await user.save({ validateBeforeSave: false }); 233 | 234 | return res 235 | .status(200) 236 | .json( 237 | new ApiResponse(200, {}, "Password updated successfully") 238 | ) 239 | }); 240 | 241 | const getCurrentUser = asyncHandler(async(req, res) => { 242 | return res 243 | .status(200) 244 | .json( 245 | new ApiResponse(200, req.user, "current user fetched successfully") 246 | ) 247 | }); 248 | 249 | const updateUserDetails = asyncHandler(async(req, res) => { 250 | const {fullName, email} = req.body; 251 | 252 | if (!fullName || !email) { 253 | throw new ApiError(400, "All fields are required"); 254 | } 255 | 256 | const user = await User.findByIdAndUpdate( 257 | req.user?._id, 258 | { 259 | $set: { 260 | fullName, 261 | email 262 | } 263 | }, 264 | { new: true } 265 | ).select("-password -refreshToken"); 266 | 267 | return res 268 | .status(200) 269 | .json( 270 | new ApiResponse(200, user, "Account details updated successfully") 271 | ) 272 | }); 273 | 274 | const updateUserAvatar = asyncHandler(async(req, res) => { 275 | const avatarLocalPath = req.file?.path; 276 | 277 | if (!avatarLocalPath) { 278 | throw new ApiError(400, "Avatar file is missing"); 279 | } 280 | 281 | const avatar = await uploadOnCloudinary(avatarLocalPath); 282 | 283 | if (!avatar.url) { 284 | throw new ApiError(400, "Error while uploading avatar"); 285 | } 286 | 287 | const user = await User.findById(req.user._id).select("avatar"); 288 | 289 | const avatarToDelete = user.avatar.public_id; 290 | 291 | const updatedUser = await User.findByIdAndUpdate( 292 | req.user?._id, 293 | { 294 | $set: { 295 | avatar: { 296 | public_id: avatar.public_id, 297 | url: avatar.secure_url 298 | } 299 | } 300 | }, 301 | { new: true } 302 | ).select("-password"); 303 | 304 | if (avatarToDelete && updatedUser.avatar.public_id) { 305 | await deleteOnCloudinary(avatarToDelete); 306 | } 307 | 308 | return res 309 | .status(200) 310 | .json( 311 | new ApiResponse(200, updatedUser, "Avatar update successfull") 312 | ) 313 | }); 314 | 315 | const updateUserCoverImage = asyncHandler(async(req, res) => { 316 | const coverImageLocalPath = req.file?.path; 317 | 318 | if (!coverImageLocalPath) { 319 | throw new ApiError(400, "coverImage file is missing"); 320 | } 321 | 322 | const coverImage = await uploadOnCloudinary(coverImageLocalPath); 323 | 324 | if (!coverImage.url) { 325 | throw new ApiError(400, "Error while uploading coverImage"); 326 | } 327 | 328 | const user = await User.findById(req.user._id).select("coverImage"); 329 | 330 | const coverImageToDelete = user.coverImage.public_id; 331 | 332 | const updatedUser = await User.findByIdAndUpdate( 333 | req.user?._id, 334 | { 335 | $set: { 336 | coverImage: { 337 | public_id: coverImage.public_id, 338 | url: coverImage.secure_url 339 | } 340 | } 341 | }, 342 | { new: true } 343 | ).select("-password"); 344 | 345 | if (coverImageToDelete && updatedUser.coverImage.public_id) { 346 | await deleteOnCloudinary(coverImageToDelete); 347 | } 348 | 349 | return res 350 | .status(200) 351 | .json( 352 | new ApiResponse(200, updatedUser, "coverImage update successfull") 353 | ) 354 | }); 355 | 356 | const getUserChannelProfile = asyncHandler(async(req, res) => { 357 | const {username} = req.params; 358 | 359 | if (!username?.trim()) { 360 | throw new ApiError(400, "username is missing"); 361 | } 362 | 363 | const channel = await User.aggregate([ 364 | { 365 | $match: { 366 | username: username?.toLowerCase() 367 | } 368 | }, 369 | { 370 | $lookup: { 371 | from: "subscriptions", // The collection to join with 372 | localField: "_id", // Field from the current collection (User) to match 373 | foreignField: "channel", // Field from the 'subscriptions' collection to match 374 | as: "subscribers" // Alias for the joined data 375 | } 376 | }, 377 | { 378 | $lookup: { 379 | from: "subscriptions", 380 | localField: "_id", 381 | foreignField: "subscriber", 382 | as: "subscribedTo" 383 | } 384 | }, 385 | { 386 | $addFields: { 387 | subcribersCount: { 388 | $size: "$subscribers" 389 | }, 390 | channelsSubscribedToCount: { 391 | $size: "$subscribedTo" 392 | }, 393 | isSubscribed: { 394 | $cond: { 395 | if: {$in: [req.user?._id, "$subscribers.subscriber"]}, 396 | then: true, 397 | else: false 398 | } 399 | } 400 | } 401 | }, 402 | { 403 | $project: { 404 | fullName: 1, 405 | username: 1, 406 | email: 1, 407 | avatar: 1, 408 | coverImage: 1, 409 | subcribersCount: 1, 410 | channelsSubscribedToCount: 1, 411 | isSubscribed: 1 412 | } 413 | } 414 | ]); 415 | 416 | // console.log(channel); 417 | if (!channel?.length) { 418 | throw new ApiError(404, "channel doesnot exist"); 419 | } 420 | 421 | return res 422 | .status(200) 423 | .json( 424 | new ApiResponse( 425 | 200, 426 | channel[0], 427 | "User channel fetced successfully" 428 | ) 429 | ) 430 | }); 431 | 432 | const getWatchHistory = asyncHandler(async(req, res) => { 433 | const user = await User.aggregate([ 434 | { 435 | $match: { 436 | _id: new mongoose.Types.ObjectId(req.user._id) 437 | } 438 | }, 439 | { 440 | $lookup: { 441 | from: "videos", 442 | localField: "watchHistory", 443 | foreignField: "_id", 444 | as: "watchHistory", 445 | pipeline: [ 446 | { 447 | $lookup: { 448 | from: "users", 449 | localField: "owner", 450 | foreignField: "_id", 451 | as: "owner", 452 | pipeline: [ 453 | { 454 | $project: { 455 | username: 1, 456 | fullName: 1, 457 | avatar: 1 458 | } 459 | } 460 | ] 461 | } 462 | }, 463 | { 464 | $addFields: { 465 | owner: { 466 | $first: "$owner" 467 | } 468 | } 469 | } 470 | ] 471 | } 472 | } 473 | ]); 474 | 475 | return res 476 | .status(200) 477 | .json( 478 | new ApiResponse( 479 | 200, 480 | user[0].watchHistory, 481 | "Watch history fetched successfully" 482 | ) 483 | ) 484 | }); 485 | 486 | 487 | 488 | export { 489 | registerUser, 490 | loginUser, 491 | logoutUser, 492 | refreshAccessToken, 493 | changeCurrentPassword, 494 | getCurrentUser, 495 | updateUserDetails, 496 | updateUserAvatar, 497 | updateUserCoverImage, 498 | getUserChannelProfile, 499 | getWatchHistory 500 | } -------------------------------------------------------------------------------- /src/controllers/video.controller.js: -------------------------------------------------------------------------------- 1 | import asyncHandler from "../utils/asyncHandler.js"; 2 | import ApiError from "../utils/apiError.js"; 3 | import { Video } from "../models/video.model.js"; 4 | import { User } from "../models/user.model.js"; 5 | import { Comment } from "../models/comment.model.js"; 6 | import { 7 | uploadOnCloudinary, 8 | deleteOnCloudinary 9 | } from "../utils/cloudinary.js"; 10 | import ApiResponse from "../utils/ApiResponse.js"; 11 | import mongoose, { isValidObjectId } from "mongoose"; 12 | import { Like } from "../models/like.model.js"; 13 | 14 | // get all videos based on query, sort, pagination 15 | const getAllVideos = asyncHandler(async (req, res) => { 16 | const { page = 1, limit = 10, query, sortBy, sortType, userId } = req.query; 17 | console.log(userId); 18 | const pipeline = []; 19 | 20 | // for using Full Text based search u need to create a search index in mongoDB atlas 21 | // you can include field mapppings in search index eg.title, description, as well 22 | // Field mappings specify which fields within your documents should be indexed for text search. 23 | // this helps in seraching only in title, desc providing faster search results 24 | // here the name of search index is 'search-videos' 25 | if (query) { 26 | pipeline.push({ 27 | $search: { 28 | index: "search-videos", 29 | text: { 30 | query: query, 31 | path: ["title", "description"] //search only on title, desc 32 | } 33 | } 34 | }); 35 | } 36 | 37 | if (userId) { 38 | if (!isValidObjectId(userId)) { 39 | throw new ApiError(400, "Invalid userId"); 40 | } 41 | 42 | pipeline.push({ 43 | $match: { 44 | owner: new mongoose.Types.ObjectId(userId) 45 | } 46 | }); 47 | } 48 | 49 | // fetch videos only that are set isPublished as true 50 | pipeline.push({ $match: { isPublished: true } }); 51 | 52 | //sortBy can be views, createdAt, duration 53 | //sortType can be ascending(-1) or descending(1) 54 | if (sortBy && sortType) { 55 | pipeline.push({ 56 | $sort: { 57 | [sortBy]: sortType === "asc" ? 1 : -1 58 | } 59 | }); 60 | } else { 61 | pipeline.push({ $sort: { createdAt: -1 } }); 62 | } 63 | 64 | pipeline.push( 65 | { 66 | $lookup: { 67 | from: "users", 68 | localField: "owner", 69 | foreignField: "_id", 70 | as: "ownerDetails", 71 | pipeline: [ 72 | { 73 | $project: { 74 | username: 1, 75 | "avatar.url": 1 76 | } 77 | } 78 | ] 79 | } 80 | }, 81 | { 82 | $unwind: "$ownerDetails" 83 | } 84 | ) 85 | 86 | const videoAggregate = Video.aggregate(pipeline); 87 | 88 | const options = { 89 | page: parseInt(page, 10), 90 | limit: parseInt(limit, 10) 91 | }; 92 | 93 | const video = await Video.aggregatePaginate(videoAggregate, options); 94 | 95 | return res 96 | .status(200) 97 | .json(new ApiResponse(200, video, "Videos fetched successfully")); 98 | }); 99 | 100 | // get video, upload to cloudinary, create video 101 | const publishAVideo = asyncHandler(async (req, res) => { 102 | const { title, description } = req.body; 103 | 104 | if ([title, description].some((field) => field?.trim() === "")) { 105 | throw new ApiError(400, "All fields are required"); 106 | } 107 | 108 | const videoFileLocalPath = req.files?.videoFile[0].path; 109 | const thumbnailLocalPath = req.files?.thumbnail[0].path; 110 | 111 | if (!videoFileLocalPath) { 112 | throw new ApiError(400, "videoFileLocalPath is required"); 113 | } 114 | 115 | if (!thumbnailLocalPath) { 116 | throw new ApiError(400, "thumbnailLocalPath is required"); 117 | } 118 | 119 | const videoFile = await uploadOnCloudinary(videoFileLocalPath); 120 | const thumbnail = await uploadOnCloudinary(thumbnailLocalPath); 121 | 122 | if (!videoFile) { 123 | throw new ApiError(400, "Video file not found"); 124 | } 125 | 126 | if (!thumbnail) { 127 | throw new ApiError(400, "Thumbnail not found"); 128 | } 129 | 130 | const video = await Video.create({ 131 | title, 132 | description, 133 | duration: videoFile.duration, 134 | videoFile: { 135 | url: videoFile.url, 136 | public_id: videoFile.public_id 137 | }, 138 | thumbnail: { 139 | url: thumbnail.url, 140 | public_id: thumbnail.public_id 141 | }, 142 | owner: req.user?._id, 143 | isPublished: false 144 | }); 145 | 146 | const videoUploaded = await Video.findById(video._id); 147 | 148 | if (!videoUploaded) { 149 | throw new ApiError(500, "videoUpload failed please try again !!!"); 150 | } 151 | 152 | return res 153 | .status(200) 154 | .json(new ApiResponse(200, video, "Video uploaded successfully")); 155 | }); 156 | 157 | // get video by id 158 | const getVideoById = asyncHandler(async (req, res) => { 159 | const { videoId } = req.params; 160 | // let userId = req.body; 161 | 162 | // userId = new mongoose.Types.ObjectId(userId) 163 | if (!isValidObjectId(videoId)) { 164 | throw new ApiError(400, "Invalid videoId"); 165 | } 166 | 167 | if (!isValidObjectId(req.user?._id)) { 168 | throw new ApiError(400, "Invalid userId"); 169 | } 170 | 171 | const video = await Video.aggregate([ 172 | { 173 | $match: { 174 | _id: new mongoose.Types.ObjectId(videoId) 175 | } 176 | }, 177 | { 178 | $lookup: { 179 | from: "likes", 180 | localField: "_id", 181 | foreignField: "video", 182 | as: "likes" 183 | } 184 | }, 185 | { 186 | $lookup: { 187 | from: "users", 188 | localField: "owner", 189 | foreignField: "_id", 190 | as: "owner", 191 | pipeline: [ 192 | { 193 | $lookup: { 194 | from: "subscriptions", 195 | localField: "_id", 196 | foreignField: "channel", 197 | as: "subscribers" 198 | } 199 | }, 200 | { 201 | $addFields: { 202 | subscribersCount: { 203 | $size: "$subscribers" 204 | }, 205 | isSubscribed: { 206 | $cond: { 207 | if: { 208 | $in: [ 209 | req.user?._id, 210 | "$subscribers.subscriber" 211 | ] 212 | }, 213 | then: true, 214 | else: false 215 | } 216 | } 217 | } 218 | }, 219 | { 220 | $project: { 221 | username: 1, 222 | "avatar.url": 1, 223 | subscribersCount: 1, 224 | isSubscribed: 1 225 | } 226 | } 227 | ] 228 | } 229 | }, 230 | { 231 | $addFields: { 232 | likesCount: { 233 | $size: "$likes" 234 | }, 235 | owner: { 236 | $first: "$owner" 237 | }, 238 | isLiked: { 239 | $cond: { 240 | if: {$in: [req.user?._id, "$likes.likedBy"]}, 241 | then: true, 242 | else: false 243 | } 244 | } 245 | } 246 | }, 247 | { 248 | $project: { 249 | "videoFile.url": 1, 250 | title: 1, 251 | description: 1, 252 | views: 1, 253 | createdAt: 1, 254 | duration: 1, 255 | comments: 1, 256 | owner: 1, 257 | likesCount: 1, 258 | isLiked: 1 259 | } 260 | } 261 | ]); 262 | 263 | if (!video) { 264 | throw new ApiError(500, "failed to fetch video"); 265 | } 266 | 267 | // increment views if video fetched successfully 268 | await Video.findByIdAndUpdate(videoId, { 269 | $inc: { 270 | views: 1 271 | } 272 | }); 273 | 274 | // add this video to user watch history 275 | await User.findByIdAndUpdate(req.user?._id, { 276 | $addToSet: { 277 | watchHistory: videoId 278 | } 279 | }); 280 | 281 | return res 282 | .status(200) 283 | .json( 284 | new ApiResponse(200, video[0], "video details fetched successfully") 285 | ); 286 | }); 287 | 288 | // update video details like title, description, thumbnail 289 | const updateVideo = asyncHandler(async (req, res) => { 290 | const { title, description } = req.body; 291 | const { videoId } = req.params; 292 | 293 | if (!isValidObjectId(videoId)) { 294 | throw new ApiError(400, "Invalid videoId"); 295 | } 296 | 297 | if (!(title && description)) { 298 | throw new ApiError(400, "title and description are required"); 299 | } 300 | 301 | const video = await Video.findById(videoId); 302 | 303 | if (!video) { 304 | throw new ApiError(404, "No video found"); 305 | } 306 | 307 | if (video?.owner.toString() !== req.user?._id.toString()) { 308 | throw new ApiError( 309 | 400, 310 | "You can't edit this video as you are not the owner" 311 | ); 312 | } 313 | 314 | //deleting old thumbnail and updating with new one 315 | const thumbnailToDelete = video.thumbnail.public_id; 316 | 317 | const thumbnailLocalPath = req.file?.path; 318 | 319 | if (!thumbnailLocalPath) { 320 | throw new ApiError(400, "thumbnail is required"); 321 | } 322 | 323 | const thumbnail = await uploadOnCloudinary(thumbnailLocalPath); 324 | 325 | if (!thumbnail) { 326 | throw new ApiError(400, "thumbnail not found"); 327 | } 328 | 329 | const updatedVideo = await Video.findByIdAndUpdate( 330 | videoId, 331 | { 332 | $set: { 333 | title, 334 | description, 335 | thumbnail: { 336 | public_id: thumbnail.public_id, 337 | url: thumbnail.url 338 | } 339 | } 340 | }, 341 | { new: true } 342 | ); 343 | 344 | if (!updatedVideo) { 345 | throw new ApiError(500, "Failed to update video please try again"); 346 | } 347 | 348 | if (updatedVideo) { 349 | await deleteOnCloudinary(thumbnailToDelete); 350 | } 351 | 352 | return res 353 | .status(200) 354 | .json(new ApiResponse(200, updatedVideo, "Video updated successfully")); 355 | }); 356 | 357 | // delete video 358 | const deleteVideo = asyncHandler(async (req, res) => { 359 | const { videoId } = req.params; 360 | 361 | if (!isValidObjectId(videoId)) { 362 | throw new ApiError(400, "Invalid videoId"); 363 | } 364 | 365 | const video = await Video.findById(videoId); 366 | 367 | if (!video) { 368 | throw new ApiError(404, "No video found"); 369 | } 370 | 371 | if (video?.owner.toString() !== req.user?._id.toString()) { 372 | throw new ApiError( 373 | 400, 374 | "You can't delete this video as you are not the owner" 375 | ); 376 | } 377 | 378 | const videoDeleted = await Video.findByIdAndDelete(video?._id); 379 | 380 | if (!videoDeleted) { 381 | throw new ApiError(400, "Failed to delete the video please try again"); 382 | } 383 | 384 | await deleteOnCloudinary(video.thumbnail.public_id); // video model has thumbnail public_id stored in it->check videoModel 385 | await deleteOnCloudinary(video.videoFile.public_id, "video"); // specify video while deleting video 386 | 387 | // delete video likes 388 | await Like.deleteMany({ 389 | video: videoId 390 | }) 391 | 392 | // delete video comments 393 | await Comment.deleteMany({ 394 | video: videoId, 395 | }) 396 | 397 | return res 398 | .status(200) 399 | .json(new ApiResponse(200, {}, "Video deleted successfully")); 400 | }); 401 | 402 | // toggle publish status of a video 403 | const togglePublishStatus = asyncHandler(async (req, res) => { 404 | const { videoId } = req.params; 405 | 406 | if (!isValidObjectId(videoId)) { 407 | throw new ApiError(400, "Invalid videoId"); 408 | } 409 | 410 | const video = await Video.findById(videoId); 411 | 412 | if (!video) { 413 | throw new ApiError(404, "Video not found"); 414 | } 415 | 416 | if (video?.owner.toString() !== req.user?._id.toString()) { 417 | throw new ApiError( 418 | 400, 419 | "You can't toogle publish status as you are not the owner" 420 | ); 421 | } 422 | 423 | const toggledVideoPublish = await Video.findByIdAndUpdate( 424 | videoId, 425 | { 426 | $set: { 427 | isPublished: !video?.isPublished 428 | } 429 | }, 430 | { new: true } 431 | ); 432 | 433 | if (!toggledVideoPublish) { 434 | throw new ApiError(500, "Failed to toogle video publish status"); 435 | } 436 | 437 | return res 438 | .status(200) 439 | .json( 440 | new ApiResponse( 441 | 200, 442 | { isPublished: toggledVideoPublish.isPublished }, 443 | "Video publish toggled successfully" 444 | ) 445 | ); 446 | }); 447 | 448 | export { 449 | publishAVideo, 450 | updateVideo, 451 | deleteVideo, 452 | getAllVideos, 453 | getVideoById, 454 | togglePublishStatus, 455 | }; 456 | -------------------------------------------------------------------------------- /src/db/dbConnect.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose"; 2 | import { DB_NAME } from "../constants.js"; 3 | 4 | const connectToDB = async () => { 5 | try { 6 | const connectionInstance = await mongoose.connect(`${process.env.MONGODB_URL}/${DB_NAME}`) 7 | console.log(`\n MongoDB Connected !! DB HOST: ${connectionInstance.connection.host}`); 8 | } catch (error) { 9 | console.log("MONGODB connection FAILED: ", error); 10 | process.exit(1) 11 | } 12 | } 13 | 14 | export default connectToDB -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import dotenv from 'dotenv' 2 | import connectToDB from './db/dbConnect.js' 3 | import app from './app.js' 4 | 5 | dotenv.config({ 6 | path: '/env' // if giving prob try "./.env" 7 | }) 8 | 9 | connectToDB() 10 | .then(() => { 11 | app.listen(process.env.PORT || 8000, () => { 12 | console.log(`Server is listening on: ${process.env.PORT}`); 13 | }) 14 | }) 15 | .catch((error) => console.log("MONGODB connection failed!!!: ", error)) 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | /**import express from 'express' 33 | const app = express() 34 | 35 | ( async() => { 36 | try { 37 | await mongoose.connect(`${process.env.MONGODB_URL}/${DB_NAME}`) 38 | app.on("error", (error) => { 39 | console.log("Error", error); 40 | throw error 41 | }) 42 | 43 | app.listen(process.env.PORT, () => { 44 | console.log(`App is listening on port ${process.env.PORT}`); 45 | }) 46 | } catch (error) { 47 | console.log("Error", error); 48 | throw error 49 | } 50 | })() 51 | **/ -------------------------------------------------------------------------------- /src/middlewares/auth.middleware.js: -------------------------------------------------------------------------------- 1 | import JWT from 'jsonwebtoken'; 2 | import asyncHandler from '../utils/asyncHandler.js'; 3 | import ApiError from '../utils/apiError.js'; 4 | import { User } from '../models/user.model.js'; 5 | 6 | export const verifyJWT = asyncHandler(async(req, _, next) => { 7 | try { 8 | const accessToken = req.cookies?.accessToken || req.header("Authorization")?.replace("Bearer ", ""); 9 | 10 | if (!accessToken) { 11 | throw new ApiError(401, "Unauthorized request"); 12 | } 13 | 14 | const decodedToken = JWT.verify(accessToken, process.env.ACCESS_TOKEN_SECRET); 15 | 16 | const user = await User.findById(decodedToken?._id).select(" -password -refreshToken"); 17 | 18 | if (!user) { 19 | throw new ApiError(401, "Invalid access token"); 20 | } 21 | 22 | req.user = user; 23 | next(); 24 | } catch (error) { 25 | throw new ApiError(401, error?.message || "Invalid access token"); 26 | } 27 | }); -------------------------------------------------------------------------------- /src/middlewares/multer.middleware.js: -------------------------------------------------------------------------------- 1 | import multer from "multer"; 2 | 3 | const storage = multer.diskStorage({ 4 | destination: function (req, file, cb) { 5 | cb(null, "./public/temp") 6 | }, 7 | filename: function (req, file, cb) { 8 | cb(null, Date.now() + file.originalname) 9 | } 10 | }) 11 | 12 | export const upload = multer({ 13 | storage, 14 | }) -------------------------------------------------------------------------------- /src/models/comment.model.js: -------------------------------------------------------------------------------- 1 | import mongoose, {Schema} from "mongoose" 2 | import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2"; 3 | 4 | const commentSchema = new Schema( 5 | { 6 | content: { 7 | type: String, 8 | required: [true, "content is required"] 9 | }, 10 | video: { 11 | type: Schema.Types.ObjectId, 12 | ref: "Video" 13 | }, 14 | owner: { 15 | type: Schema.Types.ObjectId, 16 | ref: "User" 17 | }, 18 | }, 19 | { 20 | timestamps: true 21 | } 22 | ); 23 | 24 | commentSchema.plugin(mongooseAggregatePaginate); 25 | 26 | export const Comment = mongoose.model("Comment", commentSchema); -------------------------------------------------------------------------------- /src/models/like.model.js: -------------------------------------------------------------------------------- 1 | import mongoose, {Schema} from "mongoose" 2 | 3 | const likeSchema = new Schema( 4 | { 5 | comment: { 6 | type: Schema.Types.ObjectId, 7 | ref: "Comment" 8 | }, 9 | video: { 10 | type: Schema.Types.ObjectId, 11 | ref: "Video" 12 | }, 13 | tweet: { 14 | type: Schema.Types.ObjectId, 15 | ref: "Tweet" 16 | }, 17 | likedBy: { 18 | type: Schema.Types.ObjectId, 19 | ref: "User" 20 | } 21 | }, 22 | { 23 | timestamps: true 24 | } 25 | ); 26 | 27 | export const Like = mongoose.model("Like", likeSchema); -------------------------------------------------------------------------------- /src/models/playlist.model.js: -------------------------------------------------------------------------------- 1 | import mongoose, {Schema} from "mongoose" 2 | 3 | const playlistSchema = new Schema( 4 | { 5 | name: { 6 | type: String, 7 | required: [true, "name is required"] 8 | }, 9 | description: { 10 | type: String, 11 | required: [true, "description is required"] 12 | }, 13 | videos: [ 14 | { 15 | type: Schema.Types.ObjectId, 16 | ref: "Video" 17 | } 18 | ], 19 | owner: { 20 | type: Schema.Types.ObjectId, 21 | ref: "User" 22 | } 23 | }, 24 | { 25 | timestamps: true 26 | } 27 | ); 28 | 29 | export const Playlist = mongoose.model("Playlist", playlistSchema); -------------------------------------------------------------------------------- /src/models/subscription.model.js: -------------------------------------------------------------------------------- 1 | import mongoose, {Schema} from "mongoose"; 2 | 3 | const subscriptionSchema = new Schema( 4 | { 5 | subscriber: { 6 | type: Schema.Types.ObjectId, //one who is subscribing 7 | ref: "User" 8 | }, 9 | channel: { 10 | type: Schema.Types.ObjectId, //one to whom subscriber subscribes 11 | ref: "User" 12 | }, 13 | }, 14 | { timestamps: true } 15 | ); 16 | 17 | export const Subscription = mongoose.model("Subscription", subscriptionSchema); -------------------------------------------------------------------------------- /src/models/tweet.model.js: -------------------------------------------------------------------------------- 1 | import mongoose, {Schema} from "mongoose" 2 | 3 | const tweetSchema = new Schema( 4 | { 5 | content: { 6 | type: String, 7 | required: [true, "content is required"] 8 | }, 9 | owner: { 10 | type: Schema.Types.ObjectId, 11 | ref: "User" 12 | } 13 | }, 14 | { 15 | timestamps: true 16 | } 17 | ); 18 | 19 | export const Tweet = mongoose.model("Tweet", tweetSchema); -------------------------------------------------------------------------------- /src/models/user.model.js: -------------------------------------------------------------------------------- 1 | import {Schema, model} from "mongoose"; 2 | import jwt from "jsonwebtoken" 3 | import bcrypt from "bcrypt" 4 | 5 | const userSchema = new Schema( 6 | { 7 | username: { 8 | type: String, 9 | required: [true, 'username is required'], 10 | unique: true, 11 | lowercase: true, 12 | trim: true, 13 | index: true 14 | }, 15 | email: { 16 | type: String, 17 | required: [true, 'email is required'], 18 | unique: true, 19 | lowercase: true, 20 | trim: true, 21 | }, 22 | fullName: { 23 | type: String, 24 | required: [true, 'fullname is required'], 25 | trim: true, 26 | index: true 27 | }, 28 | avatar: { 29 | type: { 30 | public_id: String, 31 | url: String //cloudinary url 32 | }, 33 | required: true 34 | }, 35 | coverImage: { 36 | type: { 37 | public_id: String, 38 | url: String //cloudinary url 39 | }, 40 | }, 41 | watchHistory: [ 42 | { 43 | type: Schema.Types.ObjectId, 44 | ref: "Video" 45 | } 46 | ], 47 | password: { 48 | type: String, 49 | required: [true, 'Password is required'] 50 | }, 51 | refreshToken: { 52 | type: String 53 | } 54 | }, 55 | { 56 | timestamps: true 57 | } 58 | ) 59 | 60 | userSchema.pre("save", async function(next){ 61 | if (!this.isModified('password')) return next() 62 | 63 | this.password = await bcrypt.hash(this.password, 10) 64 | return next() 65 | }) 66 | 67 | userSchema.methods = { 68 | comparePassword: async function(plainTextPassword) { 69 | return await bcrypt.compare(plainTextPassword, this.password) 70 | }, 71 | generateAccessToken: function(){ 72 | return jwt.sign( 73 | { 74 | _id: this._id, 75 | email: this.email, 76 | username: this.username, 77 | fullName: this.fullName 78 | }, 79 | process.env.ACCESS_TOKEN_SECRET, 80 | { 81 | expiresIn: process.env.ACCESS_TOKEN_EXPIRY 82 | } 83 | ) 84 | }, 85 | generateRefreshToken: function(){ 86 | return jwt.sign( 87 | { 88 | _id: this._id, 89 | }, 90 | process.env.REFRESH_TOKEN_SECRET, 91 | { 92 | expiresIn: process.env.REFRESH_TOKEN_EXPIRY 93 | } 94 | ) 95 | }, 96 | } 97 | 98 | export const User = model('User', userSchema) -------------------------------------------------------------------------------- /src/models/video.model.js: -------------------------------------------------------------------------------- 1 | import { Schema, model } from "mongoose"; 2 | import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2"; 3 | 4 | const videoSchema = new Schema( 5 | { 6 | videoFile: { 7 | type: { 8 | url: String, 9 | public_id: String, 10 | }, 11 | required: true, 12 | }, 13 | thumbnail: { 14 | type: { 15 | url: String, 16 | public_id: String, 17 | }, 18 | required: true, 19 | }, 20 | owner: { 21 | type: Schema.Types.ObjectId, 22 | ref: "User", 23 | }, 24 | title: { 25 | type: String, 26 | required: true, 27 | }, 28 | description: { 29 | type: String, 30 | required: true, 31 | }, 32 | duration: { 33 | type: Number, 34 | required: true, 35 | }, 36 | views: { 37 | type: Number, 38 | defaultValue: 0, 39 | }, 40 | isPublished: { 41 | type: Boolean, 42 | defaultValue: false, 43 | }, 44 | }, 45 | { 46 | timestamps: true, 47 | } 48 | ); 49 | 50 | videoSchema.plugin(mongooseAggregatePaginate); 51 | export const Video = model("Video", videoSchema); -------------------------------------------------------------------------------- /src/routes/comment.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { 3 | addComment, 4 | deleteComment, 5 | getVideoComments, 6 | updateComment, 7 | } from "../controllers/comment.controller.js"; 8 | import { verifyJWT } from "../middlewares/auth.middleware.js"; 9 | import { upload } from "../middlewares/multer.middleware.js"; 10 | 11 | const router = Router(); 12 | 13 | router.use(verifyJWT, upload.none()); // Apply verifyJWT middleware to all routes in this file 14 | 15 | router.route("/:videoId").get(getVideoComments).post(addComment); 16 | router.route("/c/:commentId").delete(deleteComment).patch(updateComment); 17 | 18 | export default router; 19 | -------------------------------------------------------------------------------- /src/routes/dashboard.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from 'express'; 2 | import { 3 | getChannelStats, 4 | getChannelVideos, 5 | } from "../controllers/dashboard.controller.js" 6 | import {verifyJWT} from "../middlewares/auth.middleware.js" 7 | 8 | const router = Router(); 9 | 10 | router.use(verifyJWT); // Apply verifyJWT middleware to all routes in this file 11 | 12 | router.route("/stats").get(getChannelStats); 13 | router.route("/videos").get(getChannelVideos); 14 | 15 | export default router -------------------------------------------------------------------------------- /src/routes/healthcheck.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { healthcheck } from "../controllers/healthcheck.controller.js"; 3 | 4 | const router = Router(); 5 | 6 | router.route("/").get(healthcheck); 7 | 8 | export default router; 9 | -------------------------------------------------------------------------------- /src/routes/like.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { 3 | getLikedVideos, 4 | toggleCommentLike, 5 | toggleVideoLike, 6 | toggleTweetLike, 7 | } from "../controllers/like.controller.js"; 8 | import { verifyJWT } from "../middlewares/auth.middleware.js"; 9 | 10 | const router = Router(); 11 | router.use(verifyJWT); // Apply verifyJWT middleware to all routes in this file 12 | 13 | router.route("/toggle/v/:videoId").post(toggleVideoLike); 14 | router.route("/toggle/c/:commentId").post(toggleCommentLike); 15 | router.route("/toggle/t/:tweetId").post(toggleTweetLike); 16 | router.route("/videos").get(getLikedVideos); 17 | 18 | export default router; 19 | -------------------------------------------------------------------------------- /src/routes/playlist.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { verifyJWT } from "../middlewares/auth.middleware.js"; 3 | import { upload } from "../middlewares/multer.middleware.js"; 4 | import { 5 | createPlaylist, 6 | updatePlaylist, 7 | deletePlaylist, 8 | addVideoToPlaylist, 9 | removeVideoFromPlaylist, 10 | getPlaylistById, 11 | getUserPlaylists, 12 | } from "../controllers/playlist.controller.js"; 13 | 14 | const router = Router(); 15 | 16 | router.use(verifyJWT, upload.none()); // Apply verifyJWT middleware to all routes in this file 17 | 18 | router.route("/").post(createPlaylist); 19 | 20 | router 21 | .route("/:playlistId") 22 | .get(getPlaylistById) 23 | .patch(updatePlaylist) 24 | .delete(deletePlaylist); 25 | 26 | router.route("/add/:videoId/:playlistId").patch(addVideoToPlaylist); 27 | router.route("/remove/:videoId/:playlistId").patch(removeVideoFromPlaylist); 28 | 29 | router.route("/user/:userId").get(getUserPlaylists); 30 | 31 | export default router; -------------------------------------------------------------------------------- /src/routes/subscription.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { 3 | getSubscribedChannels, 4 | getUserChannelSubscribers, 5 | toggleSubscription, 6 | } from "../controllers/subscription.controller.js"; 7 | import { verifyJWT } from "../middlewares/auth.middleware.js"; 8 | 9 | const router = Router(); 10 | router.use(verifyJWT); // Apply verifyJWT middleware to all routes in this file 11 | 12 | router 13 | .route("/c/:channelId") 14 | .get(getUserChannelSubscribers) 15 | .post(toggleSubscription); 16 | 17 | router.route("/u/:subscriberId").get(getSubscribedChannels); 18 | 19 | export default router; 20 | -------------------------------------------------------------------------------- /src/routes/tweet.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { verifyJWT } from "../middlewares/auth.middleware.js"; 3 | import { 4 | createTweet, 5 | deleteTweet, 6 | updateTweet, 7 | getUserTweets, 8 | } from "../controllers/tweet.controller.js"; 9 | import { upload } from "../middlewares/multer.middleware.js"; 10 | 11 | const router = Router(); 12 | 13 | router.use(verifyJWT, upload.none()); // Apply verifyJWT middleware to all routes in this file 14 | 15 | router.route("/").post(createTweet); 16 | router.route("/user/:userId").get(getUserTweets); 17 | router.route("/:tweetId").patch(updateTweet).delete(deleteTweet); 18 | 19 | export default router; 20 | -------------------------------------------------------------------------------- /src/routes/user.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { 3 | changeCurrentPassword, 4 | getCurrentUser, 5 | getUserChannelProfile, 6 | getWatchHistory, 7 | loginUser, 8 | logoutUser, 9 | refreshAccessToken, 10 | registerUser, 11 | updateUserAvatar, 12 | updateUserCoverImage, 13 | updateUserDetails 14 | } from "../controllers/user.controller.js"; 15 | import {upload} from '../middlewares/multer.middleware.js' 16 | import { verifyJWT } from "../middlewares/auth.middleware.js"; 17 | 18 | const router = Router() 19 | 20 | router.route("/register").post( 21 | upload.fields([ 22 | { 23 | name: "avatar", 24 | maxCount: 1 25 | }, 26 | { 27 | name: "coverImage", 28 | maxCount: 1 29 | } 30 | ]) , 31 | registerUser 32 | ); 33 | 34 | router.route("/login").post(upload.none(), loginUser); 35 | 36 | //secured routes 37 | router.route("/logout").post(verifyJWT, logoutUser); 38 | router.route("/refresh-token").post(refreshAccessToken); 39 | router.route("/change-password").post(upload.none(), verifyJWT, changeCurrentPassword); 40 | router.route("/current-user").get(verifyJWT, getCurrentUser); 41 | 42 | router.route("/update-user").patch(upload.none(), verifyJWT, updateUserDetails); 43 | router.route("/update-avatar").patch(verifyJWT, upload.single('avatar'), updateUserAvatar); 44 | router.route("/update-coverImg").patch(verifyJWT, upload.single('coverImage'), updateUserCoverImage); 45 | 46 | router.route("/c/:username").get(verifyJWT, getUserChannelProfile); 47 | router.route("/watch-history").get(verifyJWT, getWatchHistory); 48 | 49 | export default router -------------------------------------------------------------------------------- /src/routes/video.routes.js: -------------------------------------------------------------------------------- 1 | import { Router } from "express"; 2 | import { upload } from "../middlewares/multer.middleware.js"; 3 | import { verifyJWT } from "../middlewares/auth.middleware.js"; 4 | import { 5 | deleteVideo, 6 | getAllVideos, 7 | getVideoById, 8 | updateVideo, 9 | publishAVideo, 10 | togglePublishStatus 11 | } from "../controllers/video.controller.js"; 12 | 13 | const router = Router(); 14 | 15 | // router.use(verifyJWT); // Apply verifyJWT middleware to all routes in this file 16 | 17 | router 18 | .route("/") 19 | .get(getAllVideos) 20 | .post( 21 | verifyJWT, 22 | upload.fields([ 23 | { 24 | name: "videoFile", 25 | maxCount: 1 26 | }, 27 | { 28 | name: "thumbnail", 29 | maxCount: 1 30 | } 31 | ]), 32 | publishAVideo 33 | ); 34 | 35 | router 36 | .route("/v/:videoId") 37 | .get(verifyJWT, getVideoById) 38 | .delete(verifyJWT, deleteVideo) 39 | .patch(verifyJWT, upload.single("thumbnail"), updateVideo); 40 | 41 | router.route("/toggle/publish/:videoId").patch(verifyJWT, togglePublishStatus); 42 | 43 | export default router; 44 | -------------------------------------------------------------------------------- /src/utils/ApiResponse.js: -------------------------------------------------------------------------------- 1 | class ApiResponse { 2 | constructor(statusCode, data, message = "Success"){ 3 | this.statusCode = statusCode 4 | this.data = data 5 | this.message = message 6 | this.success = statusCode < 400 7 | } 8 | } 9 | 10 | export default ApiResponse -------------------------------------------------------------------------------- /src/utils/apiError.js: -------------------------------------------------------------------------------- 1 | class ApiError extends Error { 2 | constructor( 3 | statusCode, 4 | message = "Something went wrong", 5 | errors = [], 6 | stack = "" 7 | ) { 8 | super(message) 9 | this.statusCode = statusCode 10 | this.data = null 11 | this.message = message 12 | this.success = false 13 | this.errors = errors 14 | 15 | if (stack) { 16 | this.stack = stack 17 | } else { 18 | Error.captureStackTrace(this, this.constructor) 19 | } 20 | } 21 | } 22 | 23 | export default ApiError -------------------------------------------------------------------------------- /src/utils/asyncHandler.js: -------------------------------------------------------------------------------- 1 | const asyncHandler = (requestHandler) => { 2 | return async (req, res, next) => { 3 | try { 4 | await Promise.resolve(requestHandler(req, res, next)); 5 | } catch (error) { 6 | const statusCode = error.statusCode || 500; 7 | const errorMessage = error.message || "Internal Server Error"; 8 | res.status(statusCode).json({ 9 | success: false, 10 | error: errorMessage 11 | }); 12 | } 13 | }; 14 | }; 15 | 16 | export default asyncHandler; 17 | 18 | // const asyncHandler = (fn) => async(req, res, next) => { 19 | // try { 20 | // await fn(req, res, next) 21 | // } catch (error) { 22 | // res.status(error.code || 500).json({ 23 | // success: false, 24 | // message: error.message 25 | // }) 26 | // } 27 | // } 28 | -------------------------------------------------------------------------------- /src/utils/cloudinary.js: -------------------------------------------------------------------------------- 1 | import { v2 as cloudinary } from "cloudinary"; 2 | import fs from "fs"; 3 | 4 | cloudinary.config({ 5 | cloud_name: process.env.CLOUDINARY_CLOUD_NAME, 6 | api_key: process.env.CLOUDINARY_API_KEY, 7 | api_secret: process.env.CLOUDINARY_API_SECRET 8 | }); 9 | 10 | const uploadOnCloudinary = async (localFilePath) => { 11 | console.log(localFilePath); 12 | try { 13 | if (!localFilePath) return null; 14 | 15 | //upload to cloudinary if localFilePath exists 16 | const result = await cloudinary.uploader.upload(localFilePath, { 17 | resource_type: 'auto', 18 | }); 19 | 20 | // console.log("file uploaded to cloudinary", result.url); 21 | 22 | fs.unlinkSync(localFilePath); //remove file from localFilePath after uploading to cloudinary 23 | return result; 24 | } catch (error) { 25 | fs.unlinkSync(localFilePath); 26 | return error; 27 | } 28 | }; 29 | 30 | const deleteOnCloudinary = async (public_id, resource_type="image") => { 31 | try { 32 | if (!public_id) return null; 33 | 34 | //delete file from cloudinary 35 | const result = await cloudinary.uploader.destroy(public_id, { 36 | resource_type: `${resource_type}` 37 | }); 38 | } catch (error) { 39 | return error; 40 | console.log("delete on cloudinary failed", error); 41 | } 42 | }; 43 | 44 | export { uploadOnCloudinary, deleteOnCloudinary }; 45 | -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "builds": [ 4 | { 5 | "src": "./index.js", 6 | "use": "@vercel/node" 7 | } 8 | ], 9 | "routes": [ 10 | { 11 | "src": "/(.*)", 12 | "dest": "/" 13 | } 14 | ] 15 | } 16 | --------------------------------------------------------------------------------