style: fix linting issues met Prettier
This commit is contained in:
parent
ed8b5c919d
commit
ea5cf7abf9
26 changed files with 467 additions and 422 deletions
|
@ -1,6 +1,6 @@
|
|||
import apiClient from "@/services/api-client/api-client.ts";
|
||||
import type {AxiosResponse, ResponseType} from "axios";
|
||||
import {HttpErrorResponseException} from "@/exception/http-error-response-exception.ts";
|
||||
import type { AxiosResponse, ResponseType } from "axios";
|
||||
import { HttpErrorResponseException } from "@/exception/http-error-response-exception.ts";
|
||||
|
||||
export abstract class BaseController {
|
||||
protected basePath: string;
|
||||
|
@ -16,10 +16,7 @@ export abstract class BaseController {
|
|||
}
|
||||
|
||||
protected async get<T>(path: string, queryParams?: QueryParams, responseType?: ResponseType): Promise<T> {
|
||||
const response = await apiClient.get<T>(
|
||||
this.absolutePathFor(path),
|
||||
{params: queryParams, responseType}
|
||||
);
|
||||
const response = await apiClient.get<T>(this.absolutePathFor(path), { params: queryParams, responseType });
|
||||
BaseController.assertSuccessResponse(response);
|
||||
return response.data;
|
||||
}
|
||||
|
@ -31,7 +28,7 @@ export abstract class BaseController {
|
|||
}
|
||||
|
||||
protected async delete<T>(path: string): Promise<T> {
|
||||
const response = await apiClient.delete<T>(this.absolutePathFor(path))
|
||||
const response = await apiClient.delete<T>(this.absolutePathFor(path));
|
||||
BaseController.assertSuccessResponse(response);
|
||||
return response.data;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { ThemeController } from "@/controllers/themes.ts";
|
||||
import {LearningObjectController} from "@/controllers/learning-objects.ts";
|
||||
import {LearningPathController} from "@/controllers/learning-paths.ts";
|
||||
import { LearningObjectController } from "@/controllers/learning-objects.ts";
|
||||
import { LearningPathController } from "@/controllers/learning-paths.ts";
|
||||
|
||||
export function controllerGetter<T>(factory: new () => T): () => T {
|
||||
let instance: T | undefined;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {BaseController} from "@/controllers/base-controller.ts";
|
||||
import type {Language} from "@/data-objects/language.ts";
|
||||
import type {LearningObject} from "@/data-objects/learning-objects/learning-object.ts";
|
||||
import { BaseController } from "@/controllers/base-controller.ts";
|
||||
import type { Language } from "@/data-objects/language.ts";
|
||||
import type { LearningObject } from "@/data-objects/learning-objects/learning-object.ts";
|
||||
|
||||
export class LearningObjectController extends BaseController {
|
||||
constructor() {
|
||||
|
@ -8,10 +8,10 @@ export class LearningObjectController extends BaseController {
|
|||
}
|
||||
|
||||
async getMetadata(hruid: string, language: Language, version: number): Promise<LearningObject> {
|
||||
return this.get<LearningObject>(`/${hruid}`, {language, version});
|
||||
return this.get<LearningObject>(`/${hruid}`, { language, version });
|
||||
}
|
||||
|
||||
async getHTML(hruid: string, language: Language, version: number): Promise<Document> {
|
||||
return this.get<Document>(`/${hruid}/html`, {language, version}, "document");
|
||||
return this.get<Document>(`/${hruid}/html`, { language, version }, "document");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,32 @@
|
|||
import {BaseController} from "@/controllers/base-controller.ts";
|
||||
import {LearningPath} from "@/data-objects/learning-paths/learning-path.ts";
|
||||
import type {Language} from "@/data-objects/language.ts";
|
||||
import {single} from "@/utils/response-assertions.ts";
|
||||
import type {LearningPathDTO} from "@/data-objects/learning-paths/learning-path-dto.ts";
|
||||
import { BaseController } from "@/controllers/base-controller.ts";
|
||||
import { LearningPath } from "@/data-objects/learning-paths/learning-path.ts";
|
||||
import type { Language } from "@/data-objects/language.ts";
|
||||
import { single } from "@/utils/response-assertions.ts";
|
||||
import type { LearningPathDTO } from "@/data-objects/learning-paths/learning-path-dto.ts";
|
||||
|
||||
export class LearningPathController extends BaseController {
|
||||
constructor() {
|
||||
super("learningPath");
|
||||
}
|
||||
async search(query: string): Promise<LearningPath[]> {
|
||||
const dtos = await this.get<LearningPathDTO[]>("/", {search: query});
|
||||
return dtos.map(dto => LearningPath.fromDTO(dto));
|
||||
const dtos = await this.get<LearningPathDTO[]>("/", { search: query });
|
||||
return dtos.map((dto) => LearningPath.fromDTO(dto));
|
||||
}
|
||||
async getBy(hruid: string, language: Language, options?: {forGroup?: string, forStudent?: string}): Promise<LearningPath> {
|
||||
async getBy(
|
||||
hruid: string,
|
||||
language: Language,
|
||||
options?: { forGroup?: string; forStudent?: string },
|
||||
): Promise<LearningPath> {
|
||||
const dtos = await this.get<LearningPathDTO[]>("/", {
|
||||
hruid,
|
||||
language,
|
||||
forGroup: options?.forGroup,
|
||||
forStudent: options?.forStudent
|
||||
forStudent: options?.forStudent,
|
||||
});
|
||||
return LearningPath.fromDTO(single(dtos));
|
||||
}
|
||||
async getAllByTheme(theme: string): Promise<LearningPath[]> {
|
||||
const dtos = await this.get<LearningPathDTO[]>("/", {theme});
|
||||
return dtos.map(dto => LearningPath.fromDTO(dto));
|
||||
const dtos = await this.get<LearningPathDTO[]>("/", { theme });
|
||||
return dtos.map((dto) => LearningPath.fromDTO(dto));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue