Skip to content

Commit cd5e1a2

Browse files
committed
refactor: structure into class/models
1 parent b22e084 commit cd5e1a2

File tree

17 files changed

+1428
-54
lines changed

17 files changed

+1428
-54
lines changed

src/biome.ts renamed to src/biome/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { CAS } from "./cas";
2-
import type { BiomeProfile } from "./models/BiomeProfile";
1+
import type { CAS } from "../cas";
2+
import type { Profile } from "./models";
33
import { base64nopad } from "@scure/base";
44
import { HeaderKeys, HttpRequest, HttpRequestMethod, send } from "schwi";
5-
import { OAuth2 } from "./oauth2";
5+
import { OAuth2 } from "../cas/models";
66

77
export class Biome {
88
public static readonly oauth2 = new OAuth2("biome-prod", "https://biome.unilim.fr/authentication/callback", ["openid", "profile", "email"]);
@@ -59,7 +59,7 @@ export class Biome {
5959
return new Biome(json.token);
6060
}
6161

62-
public async profile(): Promise<BiomeProfile> {
62+
public async profile(): Promise<Profile> {
6363
const request = new HttpRequest.Builder(Biome.HOST + "/api/profile/" + this.username)
6464
.setHeader(HeaderKeys.AUTHORIZATION, `Bearer ${this.token}`)
6565
.build();

src/models/BiomeEvent.ts renamed to src/biome/models/Event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface BiomeEvent {
1+
export interface Event {
22
allDay: boolean;
33

44
/** Same calendarID provided in request parameters. */

src/models/BiomeProfile.ts renamed to src/biome/models/Profile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface BiomeProfile {
1+
export interface Profile {
22
/**
33
* base64 encoded image
44
*/

src/biome/models/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./Event";
2+
export * from "./Profile";

src/cas.ts renamed to src/cas/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { User } from "./models/User";
2-
import type { OAuth2, Tokens } from "./oauth2";
3-
import type { Services } from "./services";
1+
import type { OAuth2, Services, Tokens, User } from "./models";
42
import { HeaderKeys, HttpRequest, HttpRequestMethod, HttpRequestRedirection, send } from "schwi";
53

64
export class CAS {

src/cas/models/OAuth2.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export class OAuth2 {
2+
public constructor(
3+
public identifier: string,
4+
public callback: string,
5+
public scopes: Array<string>
6+
) {}
7+
}
File renamed without changes.

src/cas/models/Tokens.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface Tokens {
2+
access_token: string;
3+
expires_in: number;
4+
id_token: string;
5+
refresh_token: string;
6+
token_type: "Bearer";
7+
}
File renamed without changes.

src/cas/models/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from "./OAuth2";
2+
export * from "./Services";
3+
export * from "./Tokens";
4+
export * from "./User";

0 commit comments

Comments
 (0)