From 1696355df04d7f501ecb582d2b7c661d80009648 Mon Sep 17 00:00:00 2001 From: l-burrell Date: Tue, 5 Oct 2021 15:18:52 -0400 Subject: [PATCH 01/20] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 02bb6f2..864729b 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ Skeleton code for the ColorStack Sprout Fall '21 pod project. PodSpace is a private social network for pods to stay connected with each other after the program. ## Collaborators + +Lorena Burrell / CS @ GSU From 5047500d328dbef484c21347c9a48d1b0a6f96d5 Mon Sep 17 00:00:00 2001 From: l-burrell Date: Tue, 5 Oct 2021 15:20:22 -0400 Subject: [PATCH 02/20] Update HelloWorldRoute.ts --- src/routes/HelloWorldRoute.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index 3be9b5e..ac0a1f5 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,7 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: [] + podmates: ['Lorena Burrell'] }; } } From 1fcfdde66ae0a2595d1e1550d524fb66a3d5c232 Mon Sep 17 00:00:00 2001 From: Jeremy524 <57575413+Jeremy524@users.noreply.github.com> Date: Tue, 5 Oct 2021 18:56:41 -0400 Subject: [PATCH 03/20] First commit --- .env.devolopment | 13 +++++++++++++ package-lock.json | 6 +++--- package.json | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 .env.devolopment diff --git a/.env.devolopment b/.env.devolopment new file mode 100644 index 0000000..376bd63 --- /dev/null +++ b/.env.devolopment @@ -0,0 +1,13 @@ +APP_ENV=development +CLIENT_URL=http://localhost:3000 +DATABASE_URL=mongodb://localhost:27017 +DIGITAL_OCEAN_SPACES_ACCESS_KEY_ID=IGKMKWO3QUMREGPWXI6O +DIGITAL_OCEAN_SPACES_ENDPOINT=sfo3.digitaloceanspaces.com +DIGITAL_OCEAN_SPACES_NAME=colorstack-sprout +DIGITAL_OCEAN_SPACES_SECRET_ACCESS_KEY=fpf/4c/sRCo7b9zGFQ83Of0H25FB/tRfxIpMwrdRYKg +JWT_SECRET=T2pzaBwGaDynOE8SnRo3 +POD_NUMBER=15 +SPROUT_ITERATION=fa-2021 +TWILIO_ACCOUNT_SID=AC38ba630800d76c844f33c989aa375c0a +TWILIO_AUTH_TOKEN=b49872a8324530e2282fb4e69adfb2dc +TWILIO_PHONE_NUMBER=+14012082804 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8c3740e..2bab96b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7140,9 +7140,9 @@ } }, "typescript": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", - "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", + "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==", "dev": true }, "unbox-primitive": { diff --git a/package.json b/package.json index 6647255..41ac0a9 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,6 @@ "ts-jest": "^27.0.3", "ts-loader": "^9.2.4", "ts-node-dev": "^1.1.6", - "typescript": "^4.3.2" + "typescript": "^4.4.3" } } From f0eefb7cef1804e3541b34f0e21c360b74e36c15 Mon Sep 17 00:00:00 2001 From: Jeremy524 <57575413+Jeremy524@users.noreply.github.com> Date: Tue, 5 Oct 2021 19:08:04 -0400 Subject: [PATCH 04/20] First commit + quick changes --- .env.devolopment | 6 +++--- README.md | 2 ++ src/routes/HelloWorldRoute.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.env.devolopment b/.env.devolopment index 376bd63..fc764ee 100644 --- a/.env.devolopment +++ b/.env.devolopment @@ -8,6 +8,6 @@ DIGITAL_OCEAN_SPACES_SECRET_ACCESS_KEY=fpf/4c/sRCo7b9zGFQ83Of0H25FB/tRfxIpMwrdRY JWT_SECRET=T2pzaBwGaDynOE8SnRo3 POD_NUMBER=15 SPROUT_ITERATION=fa-2021 -TWILIO_ACCOUNT_SID=AC38ba630800d76c844f33c989aa375c0a -TWILIO_AUTH_TOKEN=b49872a8324530e2282fb4e69adfb2dc -TWILIO_PHONE_NUMBER=+14012082804 \ No newline at end of file +TWILIO_ACCOUNT_SID="AC38ba630800d76c844f33c989aa375c0a" +TWILIO_AUTH_TOKEN="b49872a8324530e2282fb4e69adfb2dc" +TWILIO_PHONE_NUMBER="+14012082804" \ No newline at end of file diff --git a/README.md b/README.md index 02bb6f2..5eedf8d 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ Skeleton code for the ColorStack Sprout Fall '21 pod project. PodSpace is a private social network for pods to stay connected with each other after the program. ## Collaborators + +Jeremiah Anim / CS @ JWU '23 diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index 3be9b5e..94fc07c 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,7 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: [] + podmates: ['Jeremiah Anim'] }; } } From 7b6558f28d901f55809db34b51df778ba27a7753 Mon Sep 17 00:00:00 2001 From: MELANIN BAD BOY Date: Tue, 5 Oct 2021 23:01:14 -0400 Subject: [PATCH 05/20] First Commit --- .env.devolopment | 6 +++--- README.md | 1 + src/routes/HelloWorldRoute.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.env.devolopment b/.env.devolopment index fc764ee..26d6bc8 100644 --- a/.env.devolopment +++ b/.env.devolopment @@ -8,6 +8,6 @@ DIGITAL_OCEAN_SPACES_SECRET_ACCESS_KEY=fpf/4c/sRCo7b9zGFQ83Of0H25FB/tRfxIpMwrdRY JWT_SECRET=T2pzaBwGaDynOE8SnRo3 POD_NUMBER=15 SPROUT_ITERATION=fa-2021 -TWILIO_ACCOUNT_SID="AC38ba630800d76c844f33c989aa375c0a" -TWILIO_AUTH_TOKEN="b49872a8324530e2282fb4e69adfb2dc" -TWILIO_PHONE_NUMBER="+14012082804" \ No newline at end of file +TWILIO_ACCOUNT_SID="ACe2587152a04555506e6076049a96af90" +TWILIO_AUTH_TOKEN="fc4341899f1fe78aba534d49a84745ea" +TWILIO_PHONE_NUMBER="+13186618559" \ No newline at end of file diff --git a/README.md b/README.md index f018723..9b8d91e 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,4 @@ Skeleton code for the ColorStack Sprout Fall '21 pod project. PodSpace is a priv Jeremiah Anim / CS @ JWU '23 Lorena Burrell / CS @ GSU +Ekow Thompson/ CS @UA diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index edc35ce..6d56a07 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,7 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: ['Lorena Burrell','Jeremiah Anim'] + podmates: ['Lorena Burrell','Jeremiah Anim','Ekow Thompson'] }; } } From 4a01b1f9d01a8895803b8a8545e698264dad9468 Mon Sep 17 00:00:00 2001 From: Ekow Thompson Date: Tue, 5 Oct 2021 23:09:33 -0400 Subject: [PATCH 06/20] First Commit --- src/routes/HelloWorldRoute.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index 6d56a07..106e6ba 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,7 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: ['Lorena Burrell','Jeremiah Anim','Ekow Thompson'] + podmates: ['Lorena Burrell', 'Jeremiah Anim', 'Ekow Thompson'] }; } } From 93d6b427f210ce544585cdbe74a9dc934f7b6eeb Mon Sep 17 00:00:00 2001 From: Ekow Thompson Date: Tue, 5 Oct 2021 23:12:24 -0400 Subject: [PATCH 07/20] First Commit Part2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b8d91e..03a01c9 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ Skeleton code for the ColorStack Sprout Fall '21 pod project. PodSpace is a priv Jeremiah Anim / CS @ JWU '23 Lorena Burrell / CS @ GSU -Ekow Thompson/ CS @UA +Ekow Thompson / CS @UA From 878795295c56b18772de9180f9725666037d2290 Mon Sep 17 00:00:00 2001 From: Jeremiah Anim <71801722+DynasticINF@users.noreply.github.com> Date: Wed, 6 Oct 2021 00:26:23 -0400 Subject: [PATCH 08/20] Delete .env.devolopment --- .env.devolopment | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .env.devolopment diff --git a/.env.devolopment b/.env.devolopment deleted file mode 100644 index 26d6bc8..0000000 --- a/.env.devolopment +++ /dev/null @@ -1,13 +0,0 @@ -APP_ENV=development -CLIENT_URL=http://localhost:3000 -DATABASE_URL=mongodb://localhost:27017 -DIGITAL_OCEAN_SPACES_ACCESS_KEY_ID=IGKMKWO3QUMREGPWXI6O -DIGITAL_OCEAN_SPACES_ENDPOINT=sfo3.digitaloceanspaces.com -DIGITAL_OCEAN_SPACES_NAME=colorstack-sprout -DIGITAL_OCEAN_SPACES_SECRET_ACCESS_KEY=fpf/4c/sRCo7b9zGFQ83Of0H25FB/tRfxIpMwrdRYKg -JWT_SECRET=T2pzaBwGaDynOE8SnRo3 -POD_NUMBER=15 -SPROUT_ITERATION=fa-2021 -TWILIO_ACCOUNT_SID="ACe2587152a04555506e6076049a96af90" -TWILIO_AUTH_TOKEN="fc4341899f1fe78aba534d49a84745ea" -TWILIO_PHONE_NUMBER="+13186618559" \ No newline at end of file From 9a7d5704c2554d73d4c1adfe29266a65c4819c75 Mon Sep 17 00:00:00 2001 From: tgthomp27 <72001587+tgthomp27@users.noreply.github.com> Date: Fri, 8 Oct 2021 23:24:47 -0400 Subject: [PATCH 09/20] First Commit --- README.md | 1 + src/routes/HelloWorldRoute.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03a01c9..14c7661 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,4 @@ Skeleton code for the ColorStack Sprout Fall '21 pod project. PodSpace is a priv Jeremiah Anim / CS @ JWU '23 Lorena Burrell / CS @ GSU Ekow Thompson / CS @UA +Tarah Thompson / CS @GT diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index 106e6ba..4b3fb63 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,7 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: ['Lorena Burrell', 'Jeremiah Anim', 'Ekow Thompson'] + podmates: ['Lorena Burrell', 'Jeremiah Anim', 'Ekow Thompson', 'Tarah Thompson'] }; } } From 65b7935474afdad1e37b3c9f6146639307cdad02 Mon Sep 17 00:00:00 2001 From: Edwin Garcia Date: Sat, 9 Oct 2021 11:38:20 -0400 Subject: [PATCH 10/20] Added my name and Twilio info --- README.md | 1 + src/routes/HelloWorldRoute.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 14c7661..24380f5 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,4 @@ Jeremiah Anim / CS @ JWU '23 Lorena Burrell / CS @ GSU Ekow Thompson / CS @UA Tarah Thompson / CS @GT +Edwin Garcia-Flores / CpE @UC'22 \ No newline at end of file diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index 4b3fb63..676e736 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,7 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: ['Lorena Burrell', 'Jeremiah Anim', 'Ekow Thompson', 'Tarah Thompson'] + podmates: ['Lorena Burrell', 'Jeremiah Anim', 'Ekow Thompson', 'Tarah Thompson', 'Edwin Garcia-Flores'] }; } } From caf4d28d1c1ffc5dc0fcf1a8cf9def764beb189f Mon Sep 17 00:00:00 2001 From: Edwin Garcia Date: Sat, 9 Oct 2021 20:25:07 -0400 Subject: [PATCH 11/20] AuthCode, AuthUtils updated and working --- package-lock.json | 56 +++++++++++++++++++++++-------------- package.json | 2 +- src/models/AuthCode.test.ts | 4 +-- src/models/AuthCode.ts | 11 +++++--- src/utils/AuthUtils.ts | 10 ++++--- 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2bab96b..0d0be7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1655,9 +1655,9 @@ } }, "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, "ansi-styles": { @@ -1809,11 +1809,11 @@ "dev": true }, "axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", "requires": { - "follow-redirects": "^1.10.0" + "follow-redirects": "^1.14.0" } }, "axobject-query": { @@ -3355,9 +3355,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.2.tgz", - "integrity": "sha512-yLR6WaE2lbF0x4K2qE2p9PEXKLDjUjnR/xmjS3wHAYxtlsI9MLLBJUZirAHKzUZDGLxje7w/cXR49WOUo4rbsA==" + "version": "1.14.4", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz", + "integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==" }, "form-data": { "version": "3.0.1", @@ -5654,16 +5654,17 @@ } }, "mongoose": { - "version": "5.13.5", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.5.tgz", - "integrity": "sha512-sSUAk9GWgA8r3w3nVNrNjBaDem86aevwXO8ltDMKzCf+rjnteMMQkXHQdn1ePkt7alROEPZYCAjiRjptWRSPiQ==", + "version": "5.13.10", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.13.10.tgz", + "integrity": "sha512-h1tkPu/3grQjdWjoIA3uUNWvDFDcaNGwcmBLEkK9t/kzKq4L4fB2EoA/VLjQ7WGTL/pDKH6OElBTK7x/QPRvbg==", "requires": { + "@types/bson": "1.x || 4.0.x", "@types/mongodb": "^3.5.27", "bson": "^1.1.4", "kareem": "2.3.2", - "mongodb": "3.6.10", + "mongodb": "3.6.11", "mongoose-legacy-pluralize": "1.0.2", - "mpath": "0.8.3", + "mpath": "0.8.4", "mquery": "3.2.5", "ms": "2.1.2", "optional-require": "1.0.x", @@ -5673,6 +5674,19 @@ "sliced": "1.0.1" }, "dependencies": { + "mongodb": { + "version": "3.6.11", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.11.tgz", + "integrity": "sha512-4Y4lTFHDHZZdgMaHmojtNAlqkvddX2QQBEN0K//GzxhGwlI9tZ9R0vhbjr1Decw+TF7qK0ZLjQT292XgHRRQgw==", + "requires": { + "bl": "^2.2.1", + "bson": "^1.1.4", + "denque": "^1.4.1", + "optional-require": "^1.0.3", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + } + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -5696,9 +5710,9 @@ "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" }, "mpath": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.8.3.tgz", - "integrity": "sha512-eb9rRvhDltXVNL6Fxd2zM9D4vKBxjVVQNLNijlj7uoXUy19zNDsIif5zR+pWmPCWNKwAtqyo4JveQm4nfD5+eA==" + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.8.4.tgz", + "integrity": "sha512-DTxNZomBcTWlrMW76jy1wvV37X/cNNxPW1y2Jzd4DZkAaC5ZGsm8bfGfNOthcDuRJujXLqiuS6o3Tpy0JEoh7g==" }, "mquery": { "version": "3.2.5", @@ -6897,9 +6911,9 @@ "dev": true }, "tmpl": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", - "integrity": "sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "dev": true }, "to-fast-properties": { diff --git a/package.json b/package.json index 41ac0a9..995e72b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "helmet": "^4.6.0", "jsonwebtoken": "^8.5.1", "mongodb": "^3.6.9", - "mongoose": "^5.12.13", + "mongoose": "^5.13.10", "multer": "^1.4.3", "twilio": "^3.67.0" }, diff --git a/src/models/AuthCode.test.ts b/src/models/AuthCode.test.ts index 7cd879e..e465918 100644 --- a/src/models/AuthCode.test.ts +++ b/src/models/AuthCode.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable prettier/prettier */ import { TEST_USER } from '../../jest.setup'; import AuthCode from './AuthCode'; @@ -6,9 +7,8 @@ import AuthCode from './AuthCode'; * - Remove the ".skip" from the following function. * - Go to your terminal and run the following command: * npm run test AuthCode - * - Delete this comment. */ -describe.skip('Model: AuthCode', () => { +describe('Model: AuthCode', () => { test('Should auto generate an OTP for value.', async () => { // Even though we don't specify a value for the OTP code, it should // automatically generate. diff --git a/src/models/AuthCode.ts b/src/models/AuthCode.ts index 3c566a9..ee184a5 100644 --- a/src/models/AuthCode.ts +++ b/src/models/AuthCode.ts @@ -1,3 +1,4 @@ +/* eslint-disable prettier/prettier */ import mongoose, { Document, Schema } from 'mongoose'; import AuthUtils from '../utils/AuthUtils'; @@ -7,7 +8,6 @@ import { BaseModel } from '../utils/types'; /** * (1.01) TODO: * - Read this interface. - * - Delete this comment once you've done so. */ interface IAuthCode extends BaseModel { /** @@ -39,20 +39,23 @@ const authCodeSchema: Schema = new Schema( */ { // Here's an example of how to add a field to the schema. - exampleField: { required: true, type: String, unique: false } + phoneNumber: { required: true, type: String, unique: true }, + + value: { default: AuthUtils.generateOTP, required: true, type: Number } }, - { timestamps: true } + { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } } ); /** * (1.04) TODO: - * - Add a line of code here that will elete every document in the "AuthCode" + * - Add a line of code here that will delete every document in the "AuthCode" * collection after 5 minutes (60 seconds * 5). * - To be very clear, the only way you're going to figure this out is by * Googling around for the answer. The solution is one line. * - Once you find something, add the code to this document and include a link * to the code you found in a comment. * */ +authCodeSchema.index({ createdAt: 1 }, { expireAfterSeconds: 60 * 5 }); const AuthCode: mongoose.Model = mongoose.model(Model.AUTH_CODE, authCodeSchema); diff --git a/src/utils/AuthUtils.ts b/src/utils/AuthUtils.ts index f42d3b2..d31b579 100644 --- a/src/utils/AuthUtils.ts +++ b/src/utils/AuthUtils.ts @@ -1,3 +1,4 @@ +/* eslint-disable prettier/prettier */ import jwt, { SignOptions } from 'jsonwebtoken'; import { APP } from './constants'; @@ -11,10 +12,11 @@ const generateOTP = (): number => { /** * (1.02) TODO: * - Implement this function. - * - Make sure tall the tests pass. - * - Delete this comment. + * - Make sure all the tests pass. */ - return 123456; + + return Math.floor(100000 + Math.random() * 900000); + // return 123456; }; /** @@ -68,4 +70,4 @@ const AuthUtils = { verifyToken }; -export default AuthUtils; +export default AuthUtils; \ No newline at end of file From 0bdf9e5a0a179f96b3b60aba315ece01cbb81e23 Mon Sep 17 00:00:00 2001 From: Edwin Garcia Date: Sat, 9 Oct 2021 20:28:35 -0400 Subject: [PATCH 12/20] Erased some comments and added some comments --- src/models/AuthCode.ts | 7 ++++--- src/utils/AuthUtils.ts | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/AuthCode.ts b/src/models/AuthCode.ts index ee184a5..3edf374 100644 --- a/src/models/AuthCode.ts +++ b/src/models/AuthCode.ts @@ -34,13 +34,12 @@ const authCodeSchema: Schema = new Schema( /** * (1.03) TODO: * - Create the schema for the AuthCodes that we'll save in the database. - * - Delete this comment and the example field. * - Add comment(s) to explain your work. */ + + // Schema created based on IAuthCode { - // Here's an example of how to add a field to the schema. phoneNumber: { required: true, type: String, unique: true }, - value: { default: AuthUtils.generateOTP, required: true, type: Number } }, { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } } @@ -55,6 +54,8 @@ const authCodeSchema: Schema = new Schema( * - Once you find something, add the code to this document and include a link * to the code you found in a comment. * */ + +// pulled from ColorStack notion helpful info authCodeSchema.index({ createdAt: 1 }, { expireAfterSeconds: 60 * 5 }); const AuthCode: mongoose.Model = diff --git a/src/utils/AuthUtils.ts b/src/utils/AuthUtils.ts index d31b579..cfae0ab 100644 --- a/src/utils/AuthUtils.ts +++ b/src/utils/AuthUtils.ts @@ -16,7 +16,6 @@ const generateOTP = (): number => { */ return Math.floor(100000 + Math.random() * 900000); - // return 123456; }; /** From 265fc247064284082ff0435ecff32cafa0e475d1 Mon Sep 17 00:00:00 2001 From: Ekow Thompson Date: Sat, 9 Oct 2021 20:55:44 -0400 Subject: [PATCH 13/20] Post.ts --- src/models/Post.ts | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/models/Post.ts b/src/models/Post.ts index a12f147..9a9e5c3 100644 --- a/src/models/Post.ts +++ b/src/models/Post.ts @@ -7,22 +7,12 @@ import { CommentDocument } from './Comment'; import { ReactionDocument } from './Reaction'; import User, { UserDocument } from './User'; -/** - * TODO: (3.01) - * - Read this enum. - * - Delete this comment. - */ export enum PostType { HELP = 'HELP', // Asking for help... TIL = 'TIL', // Today I learned... WIN = 'WIN' // Sharing a win... } -/** - * TODO: (3.02) - * - Read this interface. - * - Delete this comment once you've done so. - */ interface IPost extends BaseModel { /** * User that is associated with the creation of the post. @@ -55,14 +45,11 @@ export type PostDocument = Document<{}, {}, IPost> & IPost; const postSchema: Schema = new Schema( { - /** - * TODO: (3.03) - * - Create the schema for the Posts that we'll save in the database using - * the interface above as a reference. - * - Delete this comment and the example field. - * - Add comment(s) to explain your work. - */ - exampleField: { required: true, type: String } + author: { ref: Model.USER, required: true, type: ID }, + comments: { ref: Model.COMMENT, required: true, type: String }, + content: { required: true, type: String }, + reactions: { ref: Model.REACTION, required: false, type: String }, + type: { required: true, type: String, unique: true } }, { timestamps: true, From e83942164150d8e501c89480e061ff9dab9f1b7f Mon Sep 17 00:00:00 2001 From: Graceson Thompson Date: Tue, 12 Oct 2021 20:43:45 -0400 Subject: [PATCH 14/20] First Commit :) --- README.md | 1 + src/routes/HelloWorldRoute.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f018723..4f081bf 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,4 @@ Skeleton code for the ColorStack Sprout Fall '21 pod project. PodSpace is a priv Jeremiah Anim / CS @ JWU '23 Lorena Burrell / CS @ GSU +Colby Thompson / CS @ Cornell '23 diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index edc35ce..21a9e68 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,7 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: ['Lorena Burrell','Jeremiah Anim'] + podmates: ['Lorena Burrell', 'Jeremiah Anim', 'Colby Thompson'] }; } } From f9ff359389a2492bbb0d606bc88e150a65dbf35d Mon Sep 17 00:00:00 2001 From: Jeremy524 <57575413+Jeremy524@users.noreply.github.com> Date: Wed, 13 Oct 2021 22:50:07 -0400 Subject: [PATCH 15/20] Commit before pull --- .env.devolopment | 13 +++++++++++++ README.md | 2 ++ src/routes/HelloWorldRoute.ts | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .env.devolopment diff --git a/.env.devolopment b/.env.devolopment new file mode 100644 index 0000000..1792576 --- /dev/null +++ b/.env.devolopment @@ -0,0 +1,13 @@ +APP_ENV=development +CLIENT_URL=http://localhost:3000 +DATABASE_URL=mongodb://localhost:27017 +DIGITAL_OCEAN_SPACES_ACCESS_KEY_ID=IGKMKWO3QUMREGPWXI6O +DIGITAL_OCEAN_SPACES_ENDPOINT=sfo3.digitaloceanspaces.com +DIGITAL_OCEAN_SPACES_NAME=colorstack-sprout +DIGITAL_OCEAN_SPACES_SECRET_ACCESS_KEY=fpf/4c/sRCo7b9zGFQ83Of0H25FB/tRfxIpMwrdRYKg +JWT_SECRET=T2pzaBwGaDynOE8SnRo3 +POD_NUMBER=15 +SPROUT_ITERATION=fa-2021 +TWILIO_ACCOUNT_SID="AC38ba630800d76c844f33c989aa375c0a" +TWILIO_AUTH_TOKEN="c3ec8cdf227e85879009567841db2461" +TWILIO_PHONE_NUMBER="+14012082804" \ No newline at end of file diff --git a/README.md b/README.md index 02bb6f2..5eedf8d 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ Skeleton code for the ColorStack Sprout Fall '21 pod project. PodSpace is a private social network for pods to stay connected with each other after the program. ## Collaborators + +Jeremiah Anim / CS @ JWU '23 diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index 3be9b5e..94fc07c 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,7 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: [] + podmates: ['Jeremiah Anim'] }; } } From 60e09db7e8d77109d01ece77dd6c427259a75d4c Mon Sep 17 00:00:00 2001 From: Jeremy524 <57575413+Jeremy524@users.noreply.github.com> Date: Wed, 13 Oct 2021 23:06:29 -0400 Subject: [PATCH 16/20] Ticket 5: Completed --- src/models/Comment.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/models/Comment.ts b/src/models/Comment.ts index 1f0e82e..c19a190 100644 --- a/src/models/Comment.ts +++ b/src/models/Comment.ts @@ -32,14 +32,9 @@ export type CommentDocument = Document<{}, {}, IComment> & IComment; const commentSchema: Schema = new Schema( { - /** - * (5.02) TODO: - * - Create the schema for the Comments that we'll save in the database using - * the interface above as a reference. - * - Delete this comment and the example field. - * - Add comment(s) to explain your work. - */ - exampleField: { ref: Model.USER, required: false, type: ID, unique: false } + author: { ref: Model.USER, required: true, type: ID }, + content: { required: true, type: String }, + post: { ref: Model.POST, required: true, type: ID } }, { timestamps: true } ); From fd477ebcbe9a7492d4143813057dfbbcab8c5614 Mon Sep 17 00:00:00 2001 From: Jeremiah Anim <71801722+DynasticINF@users.noreply.github.com> Date: Wed, 13 Oct 2021 23:11:13 -0400 Subject: [PATCH 17/20] Delete .env.devolopment File wasn't suppose to be on repository --- .env.devolopment | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .env.devolopment diff --git a/.env.devolopment b/.env.devolopment deleted file mode 100644 index 1792576..0000000 --- a/.env.devolopment +++ /dev/null @@ -1,13 +0,0 @@ -APP_ENV=development -CLIENT_URL=http://localhost:3000 -DATABASE_URL=mongodb://localhost:27017 -DIGITAL_OCEAN_SPACES_ACCESS_KEY_ID=IGKMKWO3QUMREGPWXI6O -DIGITAL_OCEAN_SPACES_ENDPOINT=sfo3.digitaloceanspaces.com -DIGITAL_OCEAN_SPACES_NAME=colorstack-sprout -DIGITAL_OCEAN_SPACES_SECRET_ACCESS_KEY=fpf/4c/sRCo7b9zGFQ83Of0H25FB/tRfxIpMwrdRYKg -JWT_SECRET=T2pzaBwGaDynOE8SnRo3 -POD_NUMBER=15 -SPROUT_ITERATION=fa-2021 -TWILIO_ACCOUNT_SID="AC38ba630800d76c844f33c989aa375c0a" -TWILIO_AUTH_TOKEN="c3ec8cdf227e85879009567841db2461" -TWILIO_PHONE_NUMBER="+14012082804" \ No newline at end of file From 4704959cb8c1f51cc4799110927b72b4274ba687 Mon Sep 17 00:00:00 2001 From: egarcia-flores <47260584+egarcia-flores@users.noreply.github.com> Date: Fri, 15 Oct 2021 23:39:40 -0400 Subject: [PATCH 18/20] Revert "AuthCode, AuthUtils updated and working" From eba224877b337f0bcdbea038a75f4f903af9c727 Mon Sep 17 00:00:00 2001 From: Edwin Garcia Date: Fri, 15 Oct 2021 23:54:17 -0400 Subject: [PATCH 19/20] trying to re push all my week 1 work because it had been deleted --- README.md | 2 +- src/models/AuthCode.test.ts | 9 +++++++++ src/models/AuthCode.ts | 6 +++++- src/routes/HelloWorldRoute.ts | 8 +++++++- src/utils/AuthUtils.ts | 2 ++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 24380f5..c9a833a 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,4 @@ Jeremiah Anim / CS @ JWU '23 Lorena Burrell / CS @ GSU Ekow Thompson / CS @UA Tarah Thompson / CS @GT -Edwin Garcia-Flores / CpE @UC'22 \ No newline at end of file +Edwin Garcia-Flores / CpE @UC'22 \ No newline at end of file diff --git a/src/models/AuthCode.test.ts b/src/models/AuthCode.test.ts index e465918..0b65c96 100644 --- a/src/models/AuthCode.test.ts +++ b/src/models/AuthCode.test.ts @@ -8,6 +8,15 @@ import AuthCode from './AuthCode'; * - Go to your terminal and run the following command: * npm run test AuthCode */ +// describe('Model: AuthCode', () => { +// test('Should auto generate an OTP for value.', async () => { +// // Even though we don't specify a value for the OTP code, it should +// // automatically generate. +// const { value } = await AuthCode.create({ phoneNumber: TEST_USER }); +// expect(value).not.toBeNull(); +// expect(value.toString()).toHaveLength(6); +// }); +// }); describe('Model: AuthCode', () => { test('Should auto generate an OTP for value.', async () => { // Even though we don't specify a value for the OTP code, it should diff --git a/src/models/AuthCode.ts b/src/models/AuthCode.ts index 3edf374..ec2a779 100644 --- a/src/models/AuthCode.ts +++ b/src/models/AuthCode.ts @@ -39,9 +39,12 @@ const authCodeSchema: Schema = new Schema( // Schema created based on IAuthCode { - phoneNumber: { required: true, type: String, unique: true }, + // phoneNumber: { required: true, type: String, unique: true }, + phoneNumer: {required: true, type: String, unique: true}, + // value: { default: AuthUtils.generateOTP, required: true, type: Number } value: { default: AuthUtils.generateOTP, required: true, type: Number } }, + // { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } } { timestamps: true, toJSON: { virtuals: true }, toObject: { virtuals: true } } ); @@ -56,6 +59,7 @@ const authCodeSchema: Schema = new Schema( * */ // pulled from ColorStack notion helpful info +// authCodeSchema.index({ createdAt: 1 }, { expireAfterSeconds: 60 * 5 }); authCodeSchema.index({ createdAt: 1 }, { expireAfterSeconds: 60 * 5 }); const AuthCode: mongoose.Model = diff --git a/src/routes/HelloWorldRoute.ts b/src/routes/HelloWorldRoute.ts index 676e736..d76490e 100644 --- a/src/routes/HelloWorldRoute.ts +++ b/src/routes/HelloWorldRoute.ts @@ -19,7 +19,13 @@ export default class HelloWorldRoute extends BaseRoute { async content(): Promise { return { message: 'Looks like the server is up and running!', - podmates: ['Lorena Burrell', 'Jeremiah Anim', 'Ekow Thompson', 'Tarah Thompson', 'Edwin Garcia-Flores'] + podmates: [ + 'Lorena Burrell', + 'Jeremiah Anim', + 'Ekow Thompson', + 'Tarah Thompson', + 'Edwin Garcia-Flores' + ] }; } } diff --git a/src/utils/AuthUtils.ts b/src/utils/AuthUtils.ts index cfae0ab..d76edc5 100644 --- a/src/utils/AuthUtils.ts +++ b/src/utils/AuthUtils.ts @@ -15,7 +15,9 @@ const generateOTP = (): number => { * - Make sure all the tests pass. */ + // return Math.floor(100000 + Math.random() * 900000); return Math.floor(100000 + Math.random() * 900000); + }; /** From 2f63a3140e56b2781857d9b8214ec50be9171f2a Mon Sep 17 00:00:00 2001 From: tgthomp27 <72001587+tgthomp27@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:13:55 -0400 Subject: [PATCH 20/20] Ticket 6 Commit --- src/models/Comment.ts | 13 +++++++------ src/models/Post.ts | 15 ++++++++++----- src/services/TextService.test.ts | 10 ++-------- src/services/TextService.ts | 7 +++++++ 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/models/Comment.ts b/src/models/Comment.ts index c19a190..ce7d764 100644 --- a/src/models/Comment.ts +++ b/src/models/Comment.ts @@ -39,13 +39,14 @@ const commentSchema: Schema = new Schema( { timestamps: true } ); -commentSchema.pre('save', function () { +commentSchema.pre('save', async function () { if (this.isNew) { - /** - * TODO: (6.05) - * - Send a text to the author of the post notifying them that a podmate - * commented under it! - */ + const post: PostDocument = await Post.findById(this.post); + const postAuthor: UserDocument = await User.findById(post.author); + TextService.sendText({ + message: 'One of your podmates commented on your post!', + to: postAuthor.phoneNumber + }); } }); diff --git a/src/models/Post.ts b/src/models/Post.ts index 3c3e47e..89fcf3d 100644 --- a/src/models/Post.ts +++ b/src/models/Post.ts @@ -58,11 +58,16 @@ const postSchema: Schema = new Schema( const sendNotification = async function ( author: PopulatedDoc ) { - /** - * TODO: (6.04) - * - Send a text to all the users except for the author of this post letting - * them know that their podmate shared an update! - */ + const allUSers: UserDocument[] = await User.find(); + allUSers.map((user) => { + if (user != author) { + TextService.sendText( { + message: 'One of your podmates shared an update!', + to: user.phoneNumber + + }); + } + }); }; postSchema.pre('save', function () { diff --git a/src/services/TextService.test.ts b/src/services/TextService.test.ts index 9dc4894..5c1ff8c 100644 --- a/src/services/TextService.test.ts +++ b/src/services/TextService.test.ts @@ -1,14 +1,8 @@ import { APP } from '../utils/constants'; import TextService, { client } from './TextService'; -/** - * TODO: (6.05) - * - Remove the ".skip" from the following function. - * - Go to your terminal and run the following command: - * npm run test TextService - * - Delete this comment. - */ -describe.skip('TextService.sendText()', () => { + +describe('TextService.sendText()', () => { // Mock the twilio "sending" functionality. client.messages.create = jest.fn(); diff --git a/src/services/TextService.ts b/src/services/TextService.ts index f5565d9..c16d03e 100644 --- a/src/services/TextService.ts +++ b/src/services/TextService.ts @@ -40,8 +40,15 @@ const sendText = async ({ message, to }: SendTextArgs): Promise => { try { // Send the text + await client.messages.create({ + body: message, + from: APP.TWILIO_PHONE_NUMBER, + to: to + + }); } catch (e) { // What should be return if sending the text was unsuccessful? + return false; } return true;