Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • Dojo_Project_Nguyen/backend/dojobackendapi
  • dojo_project/projects/backend/dojobackendapi
2 results
Select Git revision
Show changes
Commits on Source (2)
......@@ -18,7 +18,16 @@
-->
## 4.0.0 (???)
## 4.1.0 (Upcoming)
### ✨ Feature
- Add features related to corrige (commentary, commit specific link / update, delete link)
### 🎨 Interface
- Ask for confirmation before creating an exercise that already exists
## 4.0.0 (2024-04-19)
### ✨ Feature
- Add features related to corrige (commentary, commit specific link / update, delete link)
......
......@@ -20,5 +20,6 @@ export default tseslint.config({
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-floating-promises': 'off',
}
});
\ No newline at end of file
{
"name": "dojo_backend_api",
"version": "4.0.0",
"version": "4.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dojo_backend_api",
"version": "4.0.0",
"version": "4.1.0",
"license": "AGPLv3",
"dependencies": {
"@dotenvx/dotenvx": "^0.27.1",
......
{
"name" : "dojo_backend_api",
"description" : "Backend API of the Dojo project",
"version" : "4.0.0",
"version" : "4.1.0",
"license" : "AGPLv3",
"author" : "Michaël Minelli <dojo@minelli.me>",
"main" : "dist/src/app.js",
......
......@@ -66,8 +66,8 @@ class Session {
*/
sendResponse(res: express.Response | undefined, code: number, data?: unknown, descriptionOverride?: string, internalCode?: number) {
if ( res ) {
void Promise.resolve(data).then((toReturn: unknown) => {
void this.getResponse(internalCode ?? code, toReturn, descriptionOverride).then(response => {
Promise.resolve(data).then((toReturn: unknown) => {
this.getResponse(internalCode ?? code, toReturn, descriptionOverride).then(response => {
res.status(code).json(response);
});
});
......
......@@ -46,7 +46,7 @@ class API implements WorkerTask {
this.backend.use(compression()); //Compress responses
this.backend.use((_req, res, next) => {
void DojoCliVersionHelper.getLatestVersion().then((latestVersion) => {
DojoCliVersionHelper.getLatestVersion().then(latestVersion => {
res.header('dojocli-latest-version', latestVersion);
next();
});
......
......@@ -62,7 +62,7 @@ class DojoValidators {
return new Promise((resolve, reject) => {
const template = this.getParamValue(req, path) as string;
if ( template ) {
void GitlabManager.checkTemplateAccess(template, req).then(templateAccess => {
GitlabManager.checkTemplateAccess(template, req).then(templateAccess => {
templateAccess ? resolve(true) : reject();
});
}
......
......@@ -11,7 +11,7 @@ type GetFunction = (id: string | number, ...args: Array<unknown>) => Promise<unk
class ParamsCallbackManager {
protected listenParam(paramName: string, backend: Express, getFunction: GetFunction, args: Array<unknown>, indexName: string) {
backend.param(paramName, (req: express.Request, res: express.Response, next: express.NextFunction, id: string | number) => {
void getFunction(id, ...args).then(result => {
getFunction(id, ...args).then(result => {
if ( result ) {
this.initBoundParams(req);
(req.boundParams as Record<string, unknown>)[indexName] = result;
......
......@@ -10,7 +10,7 @@ class ParamsValidatorMiddleware {
validations = ExpressValidator.checkSchema(validations);
}
void Promise.all(validations.map(validation => validation.run(req))).then(() => {
Promise.all(validations.map(validation => validation.run(req))).then(() => {
const errors = ExpressValidator.validationResult(req);
if ( !errors.isEmpty() ) {
req.session.sendResponse(res, StatusCodes.BAD_REQUEST, { errors: errors.array() });
......
......@@ -6,8 +6,8 @@ import AssignmentManager from '../managers/AssignmentManager.js';
class SecurityMiddleware {
private isConnected(checkIfConnected: boolean, req: express.Request): boolean {
return checkIfConnected && req.session.profile !== null && req.session.profile !== undefined;
private checkIfConnected(checkIfConnected: boolean, req: express.Request): boolean {
return !checkIfConnected || (req.session.profile !== null && req.session.profile !== undefined);
}
private async checkType(checkType: SecurityCheckType, req: express.Request): Promise<boolean> {
......@@ -34,6 +34,7 @@ class SecurityMiddleware {
check(checkIfConnected: boolean, ...checkTypes: Array<SecurityCheckType>): (req: express.Request, res: express.Response, next: express.NextFunction) => void {
return (req: express.Request, res: express.Response, next: express.NextFunction) => {
if ( !this.isConnected(checkIfConnected, req) ) {
if ( !this.checkIfConnected(checkIfConnected, req) ) {
return req.session.sendResponse(res, StatusCodes.UNAUTHORIZED);
}
......
......@@ -7,7 +7,7 @@ class SessionMiddleware {
registerOnBackend(backend: Express) {
backend.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
req.session = new Session();
void req.session.initSession(req, res).then(() => {
req.session.initSession(req, res).then(() => {
next();
});
});
......
Subproject commit 771f8cd079b39ec4050c5ece024dc4d70f342529
Subproject commit c2afa861bf6306ddec79ffd465a4c7b0edcd3453