diff --git a/package.json b/package.json index b097ab6..ae3bc24 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "cors": "^2.8.5", "dotenv": "^16.4.5", "express": "^4.21.0", - "localtunnel": "^2.0.2", "mongoose": "^8.6.2", "ms": "^2.1.3", "ollama": "^0.5.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ca13b4f..2efe673 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,9 +29,6 @@ importers: express: specifier: ^4.21.0 version: 4.21.0 - localtunnel: - specifier: ^2.0.2 - version: 2.0.2 mongoose: specifier: ^8.6.2 version: 8.6.2 @@ -554,9 +551,6 @@ packages: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} - axios@0.21.4: - resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==} - axios@1.7.7: resolution: {integrity: sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==} @@ -621,9 +615,6 @@ packages: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} - cliui@7.0.4: - resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} - code-red@1.0.4: resolution: {integrity: sha512-7qJWqItLA8/VPVlKJlFXU+NBlo/qyfs39aJcuMT/2ere32ZqvF5OSxgdM5xOfJJ7O429gg2HM47y8v9P+9wrNw==} @@ -701,15 +692,6 @@ packages: supports-color: optional: true - debug@4.3.2: - resolution: {integrity: sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - debug@4.3.7: resolution: {integrity: sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==} engines: {node: '>=6.0'} @@ -794,10 +776,6 @@ packages: engines: {node: '>=12'} hasBin: true - escalade@3.2.0: - resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} - engines: {node: '>=6'} - escape-html@1.0.3: resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==} @@ -888,10 +866,6 @@ packages: functions-have-names@1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} - get-caller-file@2.0.5: - resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} - engines: {node: 6.* || 8.* || >= 10.*} - get-intrinsic@1.2.4: resolution: {integrity: sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==} engines: {node: '>= 0.4'} @@ -1111,11 +1085,6 @@ packages: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} - localtunnel@2.0.2: - resolution: {integrity: sha512-n418Cn5ynvJd7m/N1d9WVJISLJF/ellZnfsLnx8WBWGzxv/ntNcFkJ1o6se5quUhCplfLGBNL5tYHiq5WF3Nug==} - engines: {node: '>=8.3.0'} - hasBin: true - locate-character@3.0.0: resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==} @@ -1227,9 +1196,6 @@ packages: ms@2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} - ms@2.1.2: - resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -1290,9 +1256,6 @@ packages: resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} engines: {node: '>= 0.8'} - openurl@1.1.1: - resolution: {integrity: sha512-d/gTkTb1i1GKz5k3XE3XFV/PxQ1k45zDqGP2OA7YhgsaLoqm6qRvARAZOFer1fcXritWlGBRCu/UgeS4HAnXAA==} - package-json-from-dist@1.0.0: resolution: {integrity: sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==} @@ -1376,10 +1339,6 @@ packages: resolution: {integrity: sha512-NcDiDkTLuPR+++OCKB0nWafEmhg/Da8aUPLPMQbK+bxKKCm1/S5he+AqYa4PlMCVBalb4/yxIRub6qkEx5yJbw==} engines: {node: '>= 0.4'} - require-directory@2.1.1: - resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} - engines: {node: '>=0.10.0'} - resolve@1.22.8: resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} hasBin: true @@ -1699,18 +1658,6 @@ packages: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} - y18n@5.0.8: - resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} - engines: {node: '>=10'} - - yargs-parser@20.2.9: - resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} - engines: {node: '>=10'} - - yargs@17.1.1: - resolution: {integrity: sha512-c2k48R0PwKIqKhPMWjeiF6y2xY/gPMUlro0sgxqXpbOIohWiLNXWslsootttv7E1e73QPAMQSg5FeySbVcpsPQ==} - engines: {node: '>=12'} - snapshots: '@ampproject/remapping@2.3.0': @@ -2110,15 +2057,9 @@ snapshots: dependencies: possible-typed-array-names: 1.0.0 - axios@0.21.4(debug@4.3.2): - dependencies: - follow-redirects: 1.15.9(debug@4.3.2) - transitivePeerDependencies: - - debug - axios@1.7.7: dependencies: - follow-redirects: 1.15.9(debug@4.3.2) + follow-redirects: 1.15.9 form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -2200,12 +2141,6 @@ snapshots: ci-info@3.9.0: {} - cliui@7.0.4: - dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 - code-red@1.0.4: dependencies: '@jridgewell/sourcemap-codec': 1.5.0 @@ -2280,10 +2215,6 @@ snapshots: dependencies: ms: 2.0.0 - debug@4.3.2: - dependencies: - ms: 2.1.2 - debug@4.3.7: dependencies: ms: 2.1.3 @@ -2391,8 +2322,6 @@ snapshots: '@esbuild/win32-ia32': 0.21.5 '@esbuild/win32-x64': 0.21.5 - escalade@3.2.0: {} - escape-html@1.0.3: {} escape-string-regexp@1.0.5: {} @@ -2471,9 +2400,7 @@ snapshots: transitivePeerDependencies: - supports-color - follow-redirects@1.15.9(debug@4.3.2): - optionalDependencies: - debug: 4.3.2 + follow-redirects@1.15.9: {} for-each@0.3.3: dependencies: @@ -2503,8 +2430,6 @@ snapshots: functions-have-names@1.2.3: {} - get-caller-file@2.0.5: {} - get-intrinsic@1.2.4: dependencies: es-errors: 1.3.0 @@ -2728,15 +2653,6 @@ snapshots: kleur@4.1.5: {} - localtunnel@2.0.2: - dependencies: - axios: 0.21.4(debug@4.3.2) - debug: 4.3.2 - openurl: 1.1.1 - yargs: 17.1.1 - transitivePeerDependencies: - - supports-color - locate-character@3.0.0: {} lru-cache@10.4.3: {} @@ -2824,8 +2740,6 @@ snapshots: ms@2.0.0: {} - ms@2.1.2: {} - ms@2.1.3: {} multer@1.4.5-lts.1: @@ -2878,8 +2792,6 @@ snapshots: dependencies: ee-first: 1.1.1 - openurl@1.1.1: {} - package-json-from-dist@1.0.0: {} parseurl@1.3.3: {} @@ -2966,8 +2878,6 @@ snapshots: es-errors: 1.3.0 set-function-name: 2.0.2 - require-directory@2.1.1: {} - resolve@1.22.8: dependencies: is-core-module: 2.15.1 @@ -3324,17 +3234,3 @@ snapshots: ws@7.5.10: {} xtend@4.0.2: {} - - y18n@5.0.8: {} - - yargs-parser@20.2.9: {} - - yargs@17.1.1: - dependencies: - cliui: 7.0.4 - escalade: 3.2.0 - get-caller-file: 2.0.5 - require-directory: 2.1.1 - string-width: 4.2.3 - y18n: 5.0.8 - yargs-parser: 20.2.9 diff --git a/server.zip b/server.zip deleted file mode 100644 index 61f2290..0000000 Binary files a/server.zip and /dev/null differ diff --git a/server/api/recipes.js b/server/api/recipes.js index b8c1700..c15797f 100644 --- a/server/api/recipes.js +++ b/server/api/recipes.js @@ -8,6 +8,7 @@ export default class RecipeAPI extends APIRoute { constructor() { super('/recipes'); + this.addSubRoute('/bulk', 'get', this.bulk); this.addSubRoute('/create', 'post', this.createRecipe); this.addSubRoute('/:id', 'get', this.get); this.addSubRoute('/:id/rate', 'post', this.rate); @@ -21,6 +22,15 @@ export default class RecipeAPI extends APIRoute { res.send(result); } + async bulk(req, res) { + + let userID = req.query.userID; + let db = req.app.get('mongo').recipes; + + let result = await db.getAll({ userID: userID }); + res.send(result); + } + async createRecipe(req, res) { let recipe = req.body; diff --git a/server/storage/collections/recipes.js b/server/storage/collections/recipes.js index dc5a576..9b522a1 100644 --- a/server/storage/collections/recipes.js +++ b/server/storage/collections/recipes.js @@ -46,7 +46,7 @@ export default class Recipes { mealType: recipe.mealType, instructions: recipe.instructions, ratingCount: 0, - rating: 0 + rating: 0, }, this.upsert); return await this.get(Id); } @@ -56,8 +56,7 @@ export default class Recipes { } async getAll(query) { - let data = await this.model.find(query); - return data + return await this.model.find(query); } async update(Id, data) { @@ -66,13 +65,6 @@ export default class Recipes { return await this.get(Id); } - async increment(Id, field, amount) { - let result = await this.get(Id); - if(!result) return null; - - return await this.get(Id); - } - async delete(Id) { let result = await this.get(Id); if(!result) return false; diff --git a/src.zip b/src.zip new file mode 100644 index 0000000..035ad26 Binary files /dev/null and b/src.zip differ diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index 09e8365..f5ccb0d 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -15,7 +15,7 @@ { #if $page.data.authInfo } Dashboard { :else } - Sign up + Sign In { /if } diff --git a/src/lib/components/form/Survey.svelte b/src/lib/components/form/Survey.svelte index 6dfd4b1..92e9505 100644 --- a/src/lib/components/form/Survey.svelte +++ b/src/lib/components/form/Survey.svelte @@ -8,10 +8,12 @@ import SignIn from './SignIn.svelte'; + console.log($page.data.authInfo); + let formData = writable({ answers: [], currentQuestion: 1, - userID: $page.data.authInfo ? $page.data.authInfo.id : null, + userID: $page.data.authInfo.user.userId || null, }); export let numQuestion = 0; @@ -91,7 +93,7 @@ } function signIn() { - goto("https://auth.fooddecisive.co/"); + location.href = 'https://auth.fooddecisive.co/'; } diff --git a/src/lib/components/recipes/RecipeTable.svelte b/src/lib/components/recipes/RecipeTable.svelte new file mode 100644 index 0000000..855b891 --- /dev/null +++ b/src/lib/components/recipes/RecipeTable.svelte @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + {#if recipes} + {#each recipes as recipe} + + {/each} + {/if} + +
NameIngredientsInstructionsRating
+ + \ No newline at end of file diff --git a/src/lib/components/recipes/RecipleEntry.svelte b/src/lib/components/recipes/RecipleEntry.svelte new file mode 100644 index 0000000..ebdcace --- /dev/null +++ b/src/lib/components/recipes/RecipleEntry.svelte @@ -0,0 +1,30 @@ + + + + {data.name} + {data.ingredients.length || 0} + {data.instructions.length || 0} + {Math.round(data.rating/((data.ratingCount == 0 ) ? data.ratingCount++ : data.ratingCount))} / 5 + + + + + + diff --git a/src/routes/+layout.js b/src/routes/+layout.js index 577b15f..19c3502 100644 --- a/src/routes/+layout.js +++ b/src/routes/+layout.js @@ -1,20 +1,14 @@ -// import {createClient} from "@propelauth/javascript"; -// const authClient = createClient({ -// authUrl: "https://auth.fooddecisive.co/", -// enableBackgroundTokenRefresh: true, -// }); +import {createClient} from "@propelauth/javascript"; +const authClient = createClient({ + authUrl: "https://auth.fooddecisive.co/", + enableBackgroundTokenRefresh: true, +}); -// export async function load() { +export async function load() { -// const authInfo = await authClient.getAuthenticationInfoOrNull(); -// console.log("authInfo", authInfo) -// if (authInfo) { -// console.log("User is logged in as", authInfo.user.email) -// } else { -// console.log("User is not logged in") -// } - -// return { -// authInfo: authInfo ? authInfo : null -// }; -// } \ No newline at end of file + const authInfo = await authClient.getAuthenticationInfoOrNull(); + console.log("authInfo", authInfo) + return { + authInfo: authInfo ? authInfo : null + }; +} \ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index d9daccd..cb581a9 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,3 +1,8 @@ + +
@@ -77,20 +82,15 @@
-

Get Started

-

Decide Your Next Bite!

+ { #if $page.data.authInfo } +

Decide Your Next Bite!

+ + { :else } +

Get Started

+

Decide Your Next Bite!

+ { /if }
+

Submitted for VTHacks-12

- -
-
-
-

Submitted for VTHacks-12

-
-
-
- - \ No newline at end of file + \ No newline at end of file