1
0
Fork 0
mirror of https://github.com/classchartsapi/classcharts-api-js.git synced 2026-05-14 11:58:13 +00:00

style: prettier and eslint

This commit is contained in:
James Cook 2022-03-12 11:37:28 +00:00
parent e1ac2b1364
commit efba7086ea
8 changed files with 33 additions and 2803 deletions

View file

@ -1,26 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/javascript-node
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local arm64/Apple Silicon.
"args": {
"VARIANT": "16-bullseye"
}
},
// Set *default* container specific settings.json values on container create.
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pnpm install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
}
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local arm64/Apple Silicon.
"args": {
"VARIANT": "16-bullseye"
}
},
// Set *default* container specific settings.json values on container create.
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["dbaeumer.vscode-eslint"],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pnpm install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
}

View file

@ -3,3 +3,6 @@ docs
node_modules
pnpm-lock.yaml
package.json
.prettierrc.json
.eslint.js
tsconfig.json

2732
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -30,13 +30,12 @@ export class ClasschartsClient {
* @param API_BASE Base API URL, this is different depending if its called as a parent or student
*/
constructor(API_BASE: string) {
this.API_BASE = API_BASE
this.API_BASE = API_BASE;
}
public async makeAuthedRequest(
path: string,
options: Omit<RequestOptions, "origin" | "path">
) {
if (!this.authCookies) throw new Error("Not authenticated");
const requestOptions: Omit<RequestOptions, "origin" | "path"> = {
...options,
@ -46,7 +45,6 @@ export class ClasschartsClient {
},
};
const request = await Undici.request(path, requestOptions);
let responseJSON;
@ -56,14 +54,12 @@ export class ClasschartsClient {
throw new Error("Invalid JSON response recieved");
}
if (responseJSON.success == 0) {
throw new Error(responseJSON.error);
}
return responseJSON.data;
}
/**
* Gets general information about the logged in student
* @returns Student object
@ -94,8 +90,6 @@ export class ClasschartsClient {
);
}
/**
* Gets the logged in students behaviour points
* @param options GetBehaviourOptions
@ -143,7 +137,7 @@ export class ClasschartsClient {
data[i].description = data[i].description.replace(/&nbsp;/g, "");
data[i].description = data[i].description.trim();
}
console.log(data)
console.log(data);
return data;
}
/**

View file

@ -1,2 +1,3 @@
export * from "./parent";
export * from "./student";
export * from "./types";

View file

@ -1,21 +1,5 @@
import Undici from "undici";
import { RequestOptions } from "undici/types/dispatcher";
import {
ActivityResponse,
AnnouncementsResponse,
BadgesResponse,
BehaviourResponse,
DetentionsResponse,
GetActivityOptions,
GetBehaviourOptions,
GetHomeworkOptions,
GetLessonsOptions,
GetPupilsResponse,
Homework,
HomeworksResponse,
LessonsResponse,
Student,
} from "./types";
import type { GetPupilsResponse } from "./types";
import { ClasschartsClient } from "./client";
import { API_BASE_PARENT, BASE_URL } from "./consts";
@ -74,7 +58,7 @@ export class ClasschartsParentClient extends ClasschartsClient {
this.sessionId = sessionID.session_id;
let pupil = await this.getPupils();
const pupil = await this.getPupils();
this.studentId = pupil[0].id;
this.studentName = pupil[0].name;
@ -84,10 +68,8 @@ export class ClasschartsParentClient extends ClasschartsClient {
* @returns an array fo Pupils connected to this parent's account
*/
async getPupils(): Promise<GetPupilsResponse> {
let pupils = this.makeAuthedRequest(this.API_BASE + "/pupils", {
return this.makeAuthedRequest(this.API_BASE + "/pupils", {
method: "GET",
});
return pupils;
}
}

View file

@ -1,22 +1,6 @@
import Undici from "undici";
import { RequestOptions } from "undici/types/dispatcher";
import {
ActivityResponse,
AnnouncementsResponse,
BadgesResponse,
BehaviourResponse,
DetentionsResponse,
GetActivityOptions,
GetBehaviourOptions,
GetHomeworkOptions,
GetLessonsOptions,
Homework,
HomeworksResponse,
LessonsResponse,
Student,
} from "./types";
import { API_BASE_STUDENT, BASE_URL } from "./consts";
import {ClasschartsClient} from "./client"
import { ClasschartsClient } from "./client";
/**
* The base client
*/
@ -31,7 +15,7 @@ export class ClasschartsStudentClient extends ClasschartsClient {
* @param dateOfBirth Student's date of birth
*/
constructor(studentCode: string, dateOfBirth?: string) {
super(API_BASE_STUDENT)
super(API_BASE_STUDENT);
this.studentCode = String(studentCode);
this.dateOfBirth = String(dateOfBirth);
}

View file

@ -299,4 +299,4 @@ export interface Pupil extends Student {
announcements_count: number;
messages_count: number;
}
export type GetPupilsResponse = Array<Pupil>;
export type GetPupilsResponse = Array<Pupil>;