-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Swagger API documentation & fix program creation parameters (#31)
* Add common folder * Add program resource * Fix eslint rule (complexity) & fix dependencies versions * add course, cours-instance * add session resource * Add prisma, scraper, program files (modules and services) * Fix prisma & add scraper files & eslint migration * chore: address sonarlint warning (if statement) * Rollback eslint flat to v8 & remove entity & format imports * add public to classes * cleanup * add ets api hekper files * add ets-program logic & (WIP) upsert programs * Remove unnecessary dtos * (wip 🚔) Add controllers & fix course routes * fix tests * Fix ProgramType relation * Add coursePrerequisite controller & service * Move scraper folder into /common * Move pdf folder into /common * fix http & add prisma to app module * fix tests (wip) & sessions route * fix tests * rename * Add schema image generator * add methods * fix * change "program to programType" relation * fix ci test * miaow miaow * test test * only run eslint on src folder * Rollback to ".test.ts" only * pdf small test * fix logging * fix PR & remove scraper folder * update enum trimester * remove file * fix param * Add swagger * fix program creation parameters & some route parameters * fix axios vulnerability * logger instead of console.log
- Loading branch information
Showing
28 changed files
with
317 additions
and
145 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions
113
...ma/migrations/20240814015008_update_id_types_and_add_program_types_relation/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,113 @@ | ||
/* | ||
Warnings: | ||
- The primary key for the `Course` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- You are about to drop the column `programId` on the `Course` table. All the data in the column will be lost. | ||
- The primary key for the `CoursePrerequisite` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- The primary key for the `Program` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- You are about to drop the column `programTypeIds` on the `Program` table. All the data in the column will be lost. | ||
- The primary key for the `ProgramCourse` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- Changed the type of `id` on the `Course` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
- Changed the type of `courseId` on the `CourseInstance` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
- Changed the type of `courseId` on the `CoursePrerequisite` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
- Changed the type of `prerequisiteId` on the `CoursePrerequisite` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
- Changed the type of `id` on the `Program` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
- Added the required column `typicalSessionIndex` to the `ProgramCourse` table without a default value. This is not possible if the table is not empty. | ||
- Changed the type of `courseId` on the `ProgramCourse` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
- Changed the type of `programId` on the `ProgramCourse` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "CourseInstance" DROP CONSTRAINT "CourseInstance_courseId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "CoursePrerequisite" DROP CONSTRAINT "CoursePrerequisite_courseId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "CoursePrerequisite" DROP CONSTRAINT "CoursePrerequisite_prerequisiteId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "ProgramCourse" DROP CONSTRAINT "ProgramCourse_courseId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "ProgramCourse" DROP CONSTRAINT "ProgramCourse_programId_fkey"; | ||
|
||
-- DropIndex | ||
DROP INDEX "Course_code_programId_idx"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Course" DROP CONSTRAINT "Course_pkey", | ||
DROP COLUMN "programId", | ||
DROP COLUMN "id", | ||
ADD COLUMN "id" INTEGER NOT NULL, | ||
ADD CONSTRAINT "Course_pkey" PRIMARY KEY ("id"); | ||
|
||
-- AlterTable | ||
ALTER TABLE "CourseInstance" DROP COLUMN "courseId", | ||
ADD COLUMN "courseId" INTEGER NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "CoursePrerequisite" DROP CONSTRAINT "CoursePrerequisite_pkey", | ||
DROP COLUMN "courseId", | ||
ADD COLUMN "courseId" INTEGER NOT NULL, | ||
DROP COLUMN "prerequisiteId", | ||
ADD COLUMN "prerequisiteId" INTEGER NOT NULL, | ||
ADD CONSTRAINT "CoursePrerequisite_pkey" PRIMARY KEY ("courseId", "prerequisiteId"); | ||
|
||
-- AlterTable | ||
ALTER TABLE "Program" DROP CONSTRAINT "Program_pkey", | ||
DROP COLUMN "programTypeIds", | ||
DROP COLUMN "id", | ||
ADD COLUMN "id" INTEGER NOT NULL, | ||
ADD CONSTRAINT "Program_pkey" PRIMARY KEY ("id"); | ||
|
||
-- AlterTable | ||
ALTER TABLE "ProgramCourse" DROP CONSTRAINT "ProgramCourse_pkey", | ||
ADD COLUMN "typicalSessionIndex" INTEGER NOT NULL, | ||
DROP COLUMN "courseId", | ||
ADD COLUMN "courseId" INTEGER NOT NULL, | ||
DROP COLUMN "programId", | ||
ADD COLUMN "programId" INTEGER NOT NULL, | ||
ADD CONSTRAINT "ProgramCourse_pkey" PRIMARY KEY ("courseId", "programId"); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_ProgramToProgramType" ( | ||
"A" INTEGER NOT NULL, | ||
"B" INTEGER NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_ProgramToProgramType_AB_unique" ON "_ProgramToProgramType"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_ProgramToProgramType_B_index" ON "_ProgramToProgramType"("B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "Course_code_idx" ON "Course"("code"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "CourseInstance_courseId_sessionId_idx" ON "CourseInstance"("courseId", "sessionId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "CourseInstance_courseId_sessionId_key" ON "CourseInstance"("courseId", "sessionId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "CourseInstance" ADD CONSTRAINT "CourseInstance_courseId_fkey" FOREIGN KEY ("courseId") REFERENCES "Course"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "CoursePrerequisite" ADD CONSTRAINT "CoursePrerequisite_courseId_fkey" FOREIGN KEY ("courseId") REFERENCES "Course"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "CoursePrerequisite" ADD CONSTRAINT "CoursePrerequisite_prerequisiteId_fkey" FOREIGN KEY ("prerequisiteId") REFERENCES "Course"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ProgramCourse" ADD CONSTRAINT "ProgramCourse_courseId_fkey" FOREIGN KEY ("courseId") REFERENCES "Course"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ProgramCourse" ADD CONSTRAINT "ProgramCourse_programId_fkey" FOREIGN KEY ("programId") REFERENCES "Program"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_ProgramToProgramType" ADD CONSTRAINT "_ProgramToProgramType_A_fkey" FOREIGN KEY ("A") REFERENCES "Program"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_ProgramToProgramType" ADD CONSTRAINT "_ProgramToProgramType_B_fkey" FOREIGN KEY ("B") REFERENCES "ProgramType"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20240814023759_update_program_code_type_to_string/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 "Program" ALTER COLUMN "code" SET DATA TYPE TEXT; |
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
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
This file was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
src/common/api-helper/ets/program/ets-program.controller.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,15 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
|
||
import { EtsProgramService } from './ets-program.service'; | ||
|
||
@ApiTags('ÉTS API') | ||
@Controller('ets/programs') | ||
export class EtsProgramController { | ||
constructor(private readonly etsProgramService: EtsProgramService) {} | ||
|
||
@Get() | ||
public async fetchAllPrograms() { | ||
return this.etsProgramService.fetchAllPrograms(); | ||
} | ||
} |
Oops, something went wrong.