diff --git a/app/(app)/uploadvideo/page.tsx b/app/(app)/uploadvideo/page.tsx index cfc92d6..2edc845 100644 --- a/app/(app)/uploadvideo/page.tsx +++ b/app/(app)/uploadvideo/page.tsx @@ -1,9 +1,114 @@ -import React from 'react' +"use client" +import { useRouter } from "next/navigation"; +import React, { useState } from "react"; +import axios from "axios"; + +import { formData } from "@/types/interfaces"; const UploadVideo = () => { + const [formData, setformData] = useState({ + file: null, + title: "", + description: "", + }); + + const [isUploading, setIsUploading] = useState(false); + + const router = useRouter(); + + const MAX_FILE_SIZE = 70 * 1024 * 1024; + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + + if (!formData.file) return; + + if (formData.file.size > MAX_FILE_SIZE) { + alert("File size too large !"); + return; + } + + setIsUploading(true); + + const formDataAppend = new FormData(); + formDataAppend.append("file", formData.file); + formDataAppend.append("title", formData.title); + formDataAppend.append("description", formData.description); + formDataAppend.append("originalSize", formData.file.size.toString()); + + try { + const response = await axios.post("/api/upload-video", formDataAppend); + + if (response.status == 200) { + console.log("File uploaded successfully"); + return; + } + } catch (error) { + console.error(error); + } finally { + setIsUploading(false); + } + }; + return ( -
UploadVideo
- ) -} +
+
+

Upload Video

+
+ +
+ + { + setformData({...formData, title: e.target.value }); + }} + className="input input-bordered w-full" + required + /> +
+ +
+ + { + setformData({...formData, description: e.target.value }); + }} + className="textarea textarea-bordered w-full" + required + /> +
+ +
+ + { + setformData({...formData, file: e.target.files?.[0] || null }); + }} + className="file-input file-input-bordered w-full" + required + /> +
+ + + +
+
+
+ ); +}; -export default UploadVideo \ No newline at end of file +export default UploadVideo; diff --git a/proxy.ts b/middleware.ts similarity index 100% rename from proxy.ts rename to middleware.ts diff --git a/package-lock.json b/package-lock.json index f84afe9..a561c17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@base-ui/react": "^1.6.0", "@clerk/nextjs": "^7.5.13", + "axios": "^1.18.1", "class-variance-authority": "^0.7.1", "cloudinary": "^2.10.0", "clsx": "^2.1.1", @@ -2304,9 +2305,9 @@ } }, "node_modules/@next/env": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.20.tgz", - "integrity": "sha512-dXh51Wvddf8daEyBXryZZEe1FdVxEWx9lgaTseLZUtC1XP/W8Wri+Z+VPOElHlByk23CyqHdc2oVByX7wsTWsw==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/env/-/env-15.5.21.tgz", + "integrity": "sha512-hjJI/GfrjWHgNguRIBzItjRRu0m3Nrz17GhxsjuHfjIvg9hyg3239REd2dpI+bpMTFuVrVprHzEQ19m++cDtbw==", "license": "MIT" }, "node_modules/@next/eslint-plugin-next": { @@ -2320,9 +2321,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.20.tgz", - "integrity": "sha512-in0yXG7/pRBVjWeEl7f7ZZETpletSMFKXVS4GJgHENTPVrJFNJKPrYewa9rpZcvdjwFece5fZP0CK34G4PxowA==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-15.5.21.tgz", + "integrity": "sha512-ZfjqPEdi6TRC/fWx7UDbwb1fbVgyh2uD5tVTRKIDZDlYM+UNuE/LafDG2fwuAoZilADpABh46OY/F5qf9JjqLQ==", "cpu": [ "arm64" ], @@ -2336,9 +2337,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.20.tgz", - "integrity": "sha512-0hsFshdPnTzGJdDTHeHJ+XPUShOpnyp9pUFDwDhqctsA0Cd8NcIVGRPtptYhgYY9DjkKgCDRkXxmgRc+CgT5Wg==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-15.5.21.tgz", + "integrity": "sha512-TlCf1NpxgQLzTrexuev75xwmNCJMd1/qkJpTVP1GRRcih93hlIBn1P72hkh8T0gnRFr6BmWksQtbyG3jT6jnww==", "cpu": [ "x64" ], @@ -2352,9 +2353,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.20.tgz", - "integrity": "sha512-DMvkoBtAABOzE6pMZRW/xNm7sKqql3wzzzZJ1R/d/rp4BCxv6LykouD3tHjGY8WdQqGpZs11t+R9AtjPxvvljw==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.5.21.tgz", + "integrity": "sha512-LXRsq1p+HvHSi7ygwNcSEEcK0zuo5jS75ZlqFHtOH+LF7qntXAJVJxah+1Pi/GyBm7EpkwU7m4EgbvIKrMqm9A==", "cpu": [ "arm64" ], @@ -2371,9 +2372,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.20.tgz", - "integrity": "sha512-RQmDfeYBtXV2FSId7dfA1hE6M/T6+g7wdbYnFQ47tw/gUBwV+CccLVejNmCGa9yLDitk83foeg8hl/3DjfYQ5g==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.5.21.tgz", + "integrity": "sha512-hyGixhFxpDKjqoev6l4KlcRBlt9AXWrGhDZwmwg49sMJM5tnKQPSi+SEj9+e5n+l/bthRGZUdh59GKIs6lQPRw==", "cpu": [ "arm64" ], @@ -2390,9 +2391,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.20.tgz", - "integrity": "sha512-DkWLEdKajJwdGt27M3i1VEO2kelTvZrK6Pcb7JvW2BY+nofWm7FBsBNDj7g7Pr1NuQ5PLJvqEqYa20GTsBDnKQ==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-15.5.21.tgz", + "integrity": "sha512-qfE+YfOba6S2+13e8qn1/UozDVNZ2clBlrs8UtDoax4s8ediu6sq93z66OEHUYlb69Tffh5JTNkgtsAKiSuugg==", "cpu": [ "x64" ], @@ -2409,9 +2410,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.20.tgz", - "integrity": "sha512-rAO5b7pKHvX+ExdmJskusDXTNbiNZfptifIPZItbUx+AOXxxTydVBsPt7Oz84DRd5mY8e0DcE8kvLj3AIfjE6w==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-15.5.21.tgz", + "integrity": "sha512-BXLGG+EvIwp/Rrgl6HY8sqvD6BOUOIRz8/naDbeLNX7mlA5H2XRcL6MW/0IGnJISfj5BA9gNhFyJj5yOoiIDJQ==", "cpu": [ "x64" ], @@ -2428,9 +2429,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.20.tgz", - "integrity": "sha512-Hp3zFsN8N8Kj9+vY6L4vnZ9EtA9eXyATu0q4EfGbZTiocgPUNSfz8NWhym6xvaOmHpJ8EuoypuU1WejCPsTFtg==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-15.5.21.tgz", + "integrity": "sha512-tNGNOlT0Wn7E4IMsSnufjXN/l2L2/AGdLLpa2vzS89SYCBuihgLn3ngLsIrvndAnWo9nAkus+4gZHTI/Ijx9HA==", "cpu": [ "arm64" ], @@ -2444,9 +2445,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.20.tgz", - "integrity": "sha512-T/L7CXpR1M0wij/xbF3rT1+7KvSkfOLr7C+ToHHWZTG2eKmb52C5WvsyGCBNtkVvDEUESWkRUbbqSH4rSbOCYQ==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-15.5.21.tgz", + "integrity": "sha512-DmIdWmC9p4rdNIiQqo8ap0+Cnj6kKtTZnuSCxoYydSc8sgpDgAg9wFhxplunak9imLV0pTvc5WVCOHwm5eHLtQ==", "cpu": [ "x64" ], @@ -4368,6 +4369,18 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/ajv": { "version": "6.15.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", @@ -4663,6 +4676,12 @@ "node": ">= 0.4" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, "node_modules/atomically": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/atomically/-/atomically-1.7.0.tgz", @@ -4708,6 +4727,18 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.18.1.tgz", + "integrity": "sha512-3nTvFlvpn9Zu/RkHUqtc7/+al4UpRW5az71ap5zccp6e8RAYEzhMTecX8Dz1wWDYrPpUoB1HAQEGEAEvUr7S9g==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.16.0", + "form-data": "^4.0.5", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" + } + }, "node_modules/axobject-query": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", @@ -5113,6 +5144,18 @@ "dev": true, "license": "MIT" }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "14.0.3", "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", @@ -5712,6 +5755,15 @@ "robust-predicates": "^3.0.2" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/denque": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", @@ -6071,7 +6123,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", - "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -6827,9 +6878,9 @@ "license": "Unlicense" }, "node_modules/fast-uri": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.3.tgz", - "integrity": "sha512-i70LwGWUduXqzicKXWshooq+sWL1K3WUU5rKZNG/0i3a1OSoX3HqhH5WbWwTmqWfor4urUakGPiRQcleRZTwOg==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.4.tgz", + "integrity": "sha512-8JnbkQ4juDyvYs4mgFGQqg4yCYtFDtUtmp2QIQq11ZZe5CFQ5wcqm1rqDgAh/QdMySuBnPzMUiJUNZG5N/AiQw==", "funding": [ { "type": "github", @@ -6965,6 +7016,26 @@ "dev": true, "license": "ISC" }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-each": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", @@ -6998,6 +7069,43 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/form-data/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -7397,7 +7505,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", - "dev": true, "license": "MIT", "dependencies": { "has-symbols": "^1.0.3" @@ -7467,6 +7574,19 @@ "url": "https://opencollective.com/express" } }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/human-signals": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-8.0.1.tgz", @@ -9006,12 +9126,12 @@ } }, "node_modules/next": { - "version": "15.5.20", - "resolved": "https://registry.npmjs.org/next/-/next-15.5.20.tgz", - "integrity": "sha512-cvyS3/geydan1xLtE3FA8VCgdoQ/Gg/dlOldFkFCbB5VcVYJV7090hQLBnvTW2PwT76Z/dHdzDZCsVhZpoOlUA==", + "version": "15.5.21", + "resolved": "https://registry.npmjs.org/next/-/next-15.5.21.tgz", + "integrity": "sha512-/TsdBtkWLhkl+NVL3Uqws2UphNd6IPzOtzSk1fHaf+0P7GQKLZDUytyhns/Ykbzdy9+YRjwG7ONvrHaaTDdFqQ==", "license": "MIT", "dependencies": { - "@next/env": "15.5.20", + "@next/env": "15.5.21", "@swc/helpers": "0.5.15", "caniuse-lite": "^1.0.30001579", "postcss": "8.4.31", @@ -9024,14 +9144,14 @@ "node": "^18.18.0 || ^19.8.0 || >= 20.0.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "15.5.20", - "@next/swc-darwin-x64": "15.5.20", - "@next/swc-linux-arm64-gnu": "15.5.20", - "@next/swc-linux-arm64-musl": "15.5.20", - "@next/swc-linux-x64-gnu": "15.5.20", - "@next/swc-linux-x64-musl": "15.5.20", - "@next/swc-win32-arm64-msvc": "15.5.20", - "@next/swc-win32-x64-msvc": "15.5.20", + "@next/swc-darwin-arm64": "15.5.21", + "@next/swc-darwin-x64": "15.5.21", + "@next/swc-linux-arm64-gnu": "15.5.21", + "@next/swc-linux-arm64-musl": "15.5.21", + "@next/swc-linux-x64-gnu": "15.5.21", + "@next/swc-linux-x64-musl": "15.5.21", + "@next/swc-win32-arm64-msvc": "15.5.21", + "@next/swc-win32-x64-msvc": "15.5.21", "sharp": "^0.34.3" }, "peerDependencies": { @@ -10046,6 +10166,15 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -10635,9 +10764,9 @@ "license": "ISC" }, "node_modules/shadcn": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/shadcn/-/shadcn-4.13.0.tgz", - "integrity": "sha512-5fuJ4jI/GcPeA/iTL4cJivCZuYQGXz/N3bIzyd+Gd/FM6xUCy2MxGG+LaDQuw2cjNy9zGPSFPTEmI048UwPTZA==", + "version": "4.14.0", + "resolved": "https://registry.npmjs.org/shadcn/-/shadcn-4.14.0.tgz", + "integrity": "sha512-WSSMmB9ERauwy0SQwE0NlSfeaoBANHtzgSjAfoEsIHpRQwVkQBiiLV8Y9yAYOj9Wf3mbCIdQt3oLGzkH7NQFiQ==", "license": "MIT", "dependencies": { "@babel/core": "^7.28.0", diff --git a/package.json b/package.json index 9445de5..c1229c5 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dependencies": { "@base-ui/react": "^1.6.0", "@clerk/nextjs": "^7.5.13", + "axios": "^1.18.1", "class-variance-authority": "^0.7.1", "cloudinary": "^2.10.0", "clsx": "^2.1.1", diff --git a/types/cloudinary.ts b/types/interfaces.ts similarity index 56% rename from types/cloudinary.ts rename to types/interfaces.ts index 71d8181..003b7eb 100644 --- a/types/cloudinary.ts +++ b/types/interfaces.ts @@ -4,3 +4,9 @@ export interface CloudinaryUploadResult { duration?: number; [key: string]: any; } + +export interface formData { + file: File | null, + title: string, + description: string, +} \ No newline at end of file diff --git a/utils/helpers.ts b/utils/helpers.ts index b722ef8..e95c761 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -1,12 +1,14 @@ import { UploadApiOptions } from "cloudinary"; import { auth } from "@clerk/nextjs/server"; -import { CloudinaryUploadResult } from "@/types/cloudinary"; -import cloudinary from "@/lib/cloudinary"; +import cloudinary from "@/lib/cloudinary"; +import { CloudinaryUploadResult } from "@/types/interfaces"; export const requireUser = async () => { - const { userId } = auth(); + const { userId } = await auth(); + console.log(userId); + if (!userId) { throw new Error("Unauthorized"); }