-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from Artur-Poffo/feat-implement-controllers
Feat(Controllers): Implement main controllers
- Loading branch information
Showing
198 changed files
with
6,468 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"cSpell.words": [ | ||
"accesstoken", | ||
"authtoken", | ||
"codespark", | ||
"dtos", | ||
"fastify", | ||
"originalname" | ||
], | ||
"CodeGPT.apiKey": "CodeGPT Plus Beta" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
prisma/migrations/20240222184213_turn_video_file_key_optional/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- DropForeignKey | ||
ALTER TABLE "videos" DROP CONSTRAINT "videos_file_key_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "videos" ALTER COLUMN "file_key" DROP NOT NULL; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "videos" ADD CONSTRAINT "videos_file_key_fkey" FOREIGN KEY ("file_key") REFERENCES "files"("key") ON DELETE SET NULL ON UPDATE CASCADE; |
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20240222230341_turn_file_key_optional/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "files" ALTER COLUMN "key" DROP NOT NULL; |
13 changes: 13 additions & 0 deletions
13
prisma/migrations/20240222232146_create_image_model/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- CreateTable | ||
CREATE TABLE "images" ( | ||
"id" TEXT NOT NULL, | ||
"file_key" TEXT, | ||
|
||
CONSTRAINT "images_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "images_file_key_key" ON "images"("file_key"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "images" ADD CONSTRAINT "images_file_key_fkey" FOREIGN KEY ("file_key") REFERENCES "files"("key") ON DELETE SET NULL ON UPDATE CASCADE; |
8 changes: 8 additions & 0 deletions
8
prisma/migrations/20240222232304_reset_file_key_optional/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
Warnings: | ||
- Made the column `key` on table `files` required. This step will fail if there are existing NULL values in that column. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "files" ALTER COLUMN "key" SET NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
7 changes: 6 additions & 1 deletion
7
src/domain/course-management/application/cryptography/encrypter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
export interface EncrypterProps { | ||
role: 'STUDENT' | 'INSTRUCTOR' | ||
sub: string | ||
} | ||
|
||
export interface Encrypter { | ||
encrypt: (payload: Record<string, unknown>) => Promise<string> | ||
encrypt: (payload: EncrypterProps) => Promise<string> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/domain/course-management/application/subscribers/on-file-uploaded.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { OnFileUploaded } from '@/domain/course-management/application/subscribers/on-file-uploaded' | ||
import { GetVideoDuration } from '@/infra/storage/utils/get-video-duration' | ||
import { InMemoryVideosRepository } from '../../../../../test/repositories/in-memory-videos-repository' | ||
import { waitFor } from '../../../../../test/utils/wait-for' | ||
import { InMemoryFilesRepository } from './../../../../../test/repositories/in-memory-files-repository' | ||
import { InMemoryImagesRepository } from './../../../../../test/repositories/in-memory-images-repository' | ||
import { FakeUploader } from './../../../../../test/storage/fake-uploader' | ||
import { UploadFileUseCase } from './../../../storage/application/use-cases/upload-file' | ||
|
||
let inMemoryFilesRepository: InMemoryFilesRepository | ||
let inMemoryImagesRepository: InMemoryImagesRepository | ||
let inMemoryVideosRepository: InMemoryVideosRepository | ||
let fakeUploader: FakeUploader | ||
let getVideoDuration: GetVideoDuration | ||
let uploadFileUseCase: UploadFileUseCase | ||
|
||
describe('On file uploaded event', () => { | ||
beforeEach(() => { | ||
inMemoryFilesRepository = new InMemoryFilesRepository() | ||
inMemoryImagesRepository = new InMemoryImagesRepository() | ||
inMemoryVideosRepository = new InMemoryVideosRepository() | ||
fakeUploader = new FakeUploader() | ||
getVideoDuration = new GetVideoDuration() | ||
uploadFileUseCase = new UploadFileUseCase( | ||
inMemoryFilesRepository, | ||
fakeUploader | ||
) | ||
|
||
new OnFileUploaded( | ||
inMemoryImagesRepository, | ||
inMemoryVideosRepository, | ||
getVideoDuration | ||
) | ||
}) | ||
|
||
it('should be able to upload a file and persist your respective entity, image or video', async () => { | ||
const result = await uploadFileUseCase.exec({ | ||
fileName: 'file.jpg', | ||
body: Buffer.from('image body'), | ||
size: 1024, | ||
fileType: 'image/jpeg' | ||
}) | ||
|
||
expect(result.isRight()).toBe(true) | ||
expect(inMemoryFilesRepository.items[0]).toMatchObject({ | ||
fileName: 'file.jpg' | ||
}) | ||
expect(fakeUploader.files[0]).toMatchObject({ | ||
fileName: 'file.jpg' | ||
}) | ||
await waitFor(() => { | ||
expect(inMemoryImagesRepository.items[0]).toMatchObject({ | ||
imageName: 'file.jpg' | ||
}) | ||
}, 5000) | ||
}) | ||
}) |
Oops, something went wrong.