diff --git a/19-semana/futurebook/src/data/feedDataBase.ts b/19-semana/futurebook/src/data/feedDataBase.ts index 2d859a3..90d4848 100644 --- a/19-semana/futurebook/src/data/feedDataBase.ts +++ b/19-semana/futurebook/src/data/feedDataBase.ts @@ -54,7 +54,7 @@ export class FeedDB extends BaseDB implements FeedGateway{ return undefined; }; - return result[0].map((post: any) => { + return await result[0].map((post: any) => { return new Feed( post.id, post.photo, diff --git a/21-22-semana/futuretube/backend/package-lock.json b/21-22-semana/futuretube/backend/package-lock.json index 665387c..4bb5152 100644 --- a/21-22-semana/futuretube/backend/package-lock.json +++ b/21-22-semana/futuretube/backend/package-lock.json @@ -472,6 +472,14 @@ "@types/node": "*" } }, + "@types/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-invOmosX0DqbpA+cE2yoHGUlF/blyf7nB0OGYBBiH27crcVm5NmFaZkLP4Ta1hGaesckCi5lVLlydNJCxkTOSg==", + "requires": { + "@types/express": "*" + } + }, "@types/dotenv": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz", @@ -1403,6 +1411,15 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "requires": { + "object-assign": "^4", + "vary": "^1" + } + }, "crc": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz", diff --git a/21-22-semana/futuretube/backend/package.json b/21-22-semana/futuretube/backend/package.json index b5fe290..3317d0c 100644 --- a/21-22-semana/futuretube/backend/package.json +++ b/21-22-semana/futuretube/backend/package.json @@ -10,11 +10,12 @@ "test": "node ./node_modules/jest/bin/jest.js", "ziplambda": "bestzip ../lambda.zip ./*", "build": "rm -rf build && tsc", - "postbuild": "cp ./package.json build && cd build && npm i && npm run ziplambda" + "postbuild": "cp ./package.json build && cd build && yarn && npm run ziplambda" }, "author": "", "license": "ISC", "dependencies": { + "@types/cors": "^2.8.6", "@types/dotenv": "^8.2.0", "@types/express": "4.17.2", "@types/jest": "^24.0.25", @@ -24,6 +25,7 @@ "@types/nodemailer": "^6.4.0", "@types/randomstring": "^1.1.6", "@types/uuid": "^3.4.6", + "cors": "^2.8.5", "dotenv": "^8.2.0", "express": "4.17.1", "jest": "^24.9.0", diff --git a/21-22-semana/futuretube/backend/src/business/entites/feed.ts b/21-22-semana/futuretube/backend/src/business/entites/feed.ts index c8ef017..ee5530e 100644 --- a/21-22-semana/futuretube/backend/src/business/entites/feed.ts +++ b/21-22-semana/futuretube/backend/src/business/entites/feed.ts @@ -8,10 +8,11 @@ export class Feed extends Video{ description: string, creationDate: Date, user_id: string, + photo: string, private name: string, - private photo: string + private userPhoto: string ){ - super(id, title, link, description, creationDate, user_id) + super(id, title, link, description, creationDate, user_id, photo) } public getName(): string{ @@ -22,11 +23,11 @@ export class Feed extends Video{ this.name = name; }; - public getPhoto(): string{ - return this.photo; + public getUserPhoto(): string{ + return this.userPhoto; } - public setPhoto(photo: string): void{ - this.photo = photo; + public setUserPhoto(userPhoto: string): void{ + this.userPhoto = userPhoto; } } \ No newline at end of file diff --git a/21-22-semana/futuretube/backend/src/business/entites/video.ts b/21-22-semana/futuretube/backend/src/business/entites/video.ts index 1f0a04b..4537ad9 100644 --- a/21-22-semana/futuretube/backend/src/business/entites/video.ts +++ b/21-22-semana/futuretube/backend/src/business/entites/video.ts @@ -5,8 +5,8 @@ export class Video{ private link: string, private description: string, private creationDate: Date, - private user_id: string - + private user_id: string, + private photo: string ){} public getId(): string{ @@ -56,4 +56,12 @@ export class Video{ public setUser_id(user_id: string): void{ this.user_id = user_id } + + public getPhoto(): string{ + return this.photo + } + + public setPhoto(photo: string): void{ + this.photo = photo + } } \ No newline at end of file diff --git a/21-22-semana/futuretube/backend/src/business/error/JwtMustBeProvided.ts b/21-22-semana/futuretube/backend/src/business/error/JwtMustBeProvided.ts new file mode 100644 index 0000000..d6bd9b4 --- /dev/null +++ b/21-22-semana/futuretube/backend/src/business/error/JwtMustBeProvided.ts @@ -0,0 +1,7 @@ +import { BaseError } from "./BaseError"; + +export class JwtMustBeProvided extends BaseError { + constructor() { + super(404, "You need a token to use this endpoint"); + } +} \ No newline at end of file diff --git a/21-22-semana/futuretube/backend/src/business/gateways/userGateway.ts b/21-22-semana/futuretube/backend/src/business/gateways/userGateway.ts index 5164b9d..ed25932 100644 --- a/21-22-semana/futuretube/backend/src/business/gateways/userGateway.ts +++ b/21-22-semana/futuretube/backend/src/business/gateways/userGateway.ts @@ -4,5 +4,6 @@ export interface UserGateway { signUp(user: User): Promise; login(email: string): Promise; getAllUsers(): Promise; - getUserById(id: string, email: string): Promise; + getUserById(id: string): Promise; + updatePassword(id: string, password: string): Promise; } \ No newline at end of file diff --git a/21-22-semana/futuretube/backend/src/business/gateways/videoGateway.ts b/21-22-semana/futuretube/backend/src/business/gateways/videoGateway.ts index 0f45c8b..2c9820f 100644 --- a/21-22-semana/futuretube/backend/src/business/gateways/videoGateway.ts +++ b/21-22-semana/futuretube/backend/src/business/gateways/videoGateway.ts @@ -4,9 +4,11 @@ import { Feed } from "../entites/feed"; export interface VideoGateway{ checkVideoByLink(link: string): Promise