feat: docs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Aravinth Manivannan 2023-09-19 02:42:52 +05:30
parent 1fc88f8166
commit 8c5d70a5f7
Signed by: realaravinth
GPG key ID: F8F50389936984FF
7 changed files with 23 additions and 1 deletions

View file

@ -7,7 +7,7 @@
"build": "swc ./src/index.ts -o dist/index.js", "build": "swc ./src/index.ts -o dist/index.js",
"lint": "prettier --write ./src/*", "lint": "prettier --write ./src/*",
"test": "jest", "test": "jest",
"doc": "typedoc ./src/index.ts" "doc": "typedoc ./src/index.ts ./src/auth.ts ./src/spec/**"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",

View file

@ -32,6 +32,9 @@ class Forgejo {
this.token = new Auth(token); this.token = new Auth(token);
} }
/**
* Get access token
*/
getTokenAuth(): Auth { getTokenAuth(): Auth {
if (this.token) { if (this.token) {
return this.token; return this.token;
@ -40,6 +43,9 @@ class Forgejo {
} }
} }
/**
* Get access token in header format for the fetch API
*/
getTokenAuthHeader() { getTokenAuthHeader() {
return { Authorization: `token ${this.getTokenAuth().getToken()}` }; return { Authorization: `token ${this.getTokenAuth().getToken()}` };
} }
@ -201,6 +207,9 @@ class Forgejo {
return issue; return issue;
} }
/**
* Fetch and save comments for the issue objects
*/
async getCommentsForIssue(issue: Issue): Promise<Issue> { async getCommentsForIssue(issue: Issue): Promise<Issue> {
// TODO: check if issue.number != issue.id causes problems. I'm assuming // TODO: check if issue.number != issue.id causes problems. I'm assuming
// Issue.number is the local repository issue ID and issue.id is DB ID // Issue.number is the local repository issue ID and issue.id is DB ID

View file

@ -4,6 +4,9 @@
import User from "./user"; import User from "./user";
/**
* Subset schema of comment object returned by Forgejo REST API
*/
type Comment = { type Comment = {
id: number; id: number;
html_url: URL; html_url: URL;

View file

@ -5,6 +5,9 @@
import User from "./user"; import User from "./user";
import Comment from "./comments"; import Comment from "./comments";
/**
* Subset schema of issue object returned by Forgejo REST API
*/
type Issue = { type Issue = {
id: number; id: number;
url: URL; url: URL;

View file

@ -13,6 +13,9 @@ type Subject = {
state: string; state: string;
}; };
/**
* Subset schema of notification object returned by Forgejo REST API
*/
type Notification = { type Notification = {
id: number; id: number;
repository: Repository; repository: Repository;

View file

@ -4,6 +4,9 @@
import User from "./user"; import User from "./user";
/**
* Subset schema of repository object returned by Forgejo REST API
*/
type Repository = { type Repository = {
id: number; id: number;
name: string; name: string;

View file

@ -2,6 +2,7 @@
// //
// SPDX-License-Identifier: AGPL-3.0-or-later // SPDX-License-Identifier: AGPL-3.0-or-later
/** Subset schema of user object returned by Forgejo REST API. */
type User = { type User = {
id: number; id: number;
login: string; login: string;