-
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 error filter & add program and session codes params to routes (#17)
* add exception filter #7 * add program and session params to routes #11 * add error when empty courses * change name of parameter * change planification param * remove unused variables * feat: Add initial program data for scraping * update programs code
- Loading branch information
Showing
10 changed files
with
181 additions
and
55 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,87 @@ | ||
[ | ||
{ | ||
"code": "7625", | ||
"type": "premier-cycle", | ||
"url": "baccalaureat-genie-construction" | ||
}, | ||
{ | ||
"code": "7694", | ||
"type": "premier-cycle", | ||
"url": "baccalaureat-genie-electrique" | ||
}, | ||
{ | ||
"code": "7084", | ||
"type": "premier-cycle", | ||
"url": "baccalaureat-genie-logiciel" | ||
}, | ||
{ | ||
"code": "7684", | ||
"type": "premier-cycle", | ||
"url": "baccalaureat-genie-mecanique" | ||
}, | ||
{ | ||
"code": "6556", | ||
"type": "premier-cycle", | ||
"url": "baccalaureat-genie-operations-logistique" | ||
}, | ||
{ | ||
"code": "6557", | ||
"type": "premier-cycle", | ||
"url": "baccalaureat-genie-production-automatisee" | ||
}, | ||
{ | ||
"code": "7086", | ||
"type": "premier-cycle", | ||
"url": "baccalaureat-genie-des-ti" | ||
}, | ||
{ | ||
"code": "6646", | ||
"type": "premier-cycle", | ||
"url": "baccalaureat-informatique-distribuee" | ||
}, | ||
{ | ||
"code": "5766", | ||
"type": "premier-cycle", | ||
"url": "cheminement-universitaire-technologie" | ||
}, | ||
{ | ||
"code": "4567", | ||
"type": "premier-cycle", | ||
"url": "certificat-economie-estimation" | ||
}, | ||
{ | ||
"code": "4412", | ||
"type": "premier-cycle", | ||
"url": "certificat-gestion-assurance-qualite" | ||
}, | ||
{ | ||
"code": "4563", | ||
"type": "premier-cycle", | ||
"url": "certificat-gestion-construction" | ||
}, | ||
{ | ||
"code": "4684", | ||
"type": "premier-cycle", | ||
"url": "certificat-gestion-immobiliere" | ||
}, | ||
{ | ||
"code": "4329", | ||
"type": "premier-cycle", | ||
"url": "certificat-production-industrielle" | ||
}, | ||
{ | ||
"code": "4288", | ||
"type": "premier-cycle", | ||
"url": "certificat-telecommunications" | ||
}, | ||
{ | ||
"code": "1822", | ||
"type": "deuxieme-cycle", | ||
"url": "maitrise-genie-logiciel" | ||
}, | ||
{ | ||
"code": "3178", | ||
"type": "deuxieme-cycle", | ||
"url": "dess-technologies-information" | ||
} | ||
] |
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 +0,0 @@ | ||
//This will contain the seed data for university programs | ||
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,6 @@ | ||
export const ERROR_MESSAGES = { | ||
ERROR_PARSING_PDF: 'An error occurred while parsing the PDF.', | ||
REQUIRED_PDF_URL: 'PDF URL is required and must be valid.', | ||
REQUIRED_SESSION_AND_PROGRAM_CODE: | ||
'Session code and program code are required.', | ||
}; |
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,24 @@ | ||
import { | ||
ArgumentsHost, | ||
Catch, | ||
ExceptionFilter, | ||
HttpException, | ||
} from '@nestjs/common'; | ||
import { Request, Response } from 'express'; | ||
|
||
@Catch(HttpException) | ||
export class HttpExceptionFilter implements ExceptionFilter { | ||
public catch(exception: HttpException, host: ArgumentsHost) { | ||
const ctx = host.switchToHttp(); | ||
const response = ctx.getResponse<Response>(); | ||
const request = ctx.getRequest<Request>(); | ||
const status = exception.getStatus(); | ||
|
||
response.status(status).json({ | ||
statusCode: status, | ||
timestamp: new Date().toISOString(), | ||
path: request.url, | ||
message: exception.message || 'Internal Server Error', | ||
}); | ||
} | ||
} |
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,9 +1,11 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
|
||
import { AppModule } from './app.module'; | ||
import { HttpExceptionFilter } from './http-exception.filter'; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule); | ||
app.useGlobalFilters(new HttpExceptionFilter()); | ||
await app.listen(process.env.PORT ? parseInt(process.env.PORT) : 3000); | ||
} | ||
bootstrap(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3000,7 +3000,7 @@ expect@^29.0.0, expect@^29.7.0: | |
jest-message-util "^29.7.0" | ||
jest-util "^29.7.0" | ||
|
||
[email protected]: | ||
[email protected], express@^4.19.2: | ||
version "4.19.2" | ||
resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465" | ||
integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q== | ||
|
@@ -6348,6 +6348,7 @@ which@^2.0.1: | |
isexe "^2.0.0" | ||
|
||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: | ||
name wrap-ansi-cjs | ||
version "7.0.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" | ||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== | ||
|