This commit is contained in:
parent
fa1d7427ab
commit
f5fe8a90e5
3 changed files with 20 additions and 3 deletions
|
@ -4,7 +4,6 @@
|
|||
"version": "0.1.0-alpha-1",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"type": "module",
|
||||
"web": "dist/web.js",
|
||||
"module": "dist/web.js",
|
||||
"main": "dist/web.js",
|
||||
"keywords": [
|
||||
|
@ -13,7 +12,8 @@
|
|||
],
|
||||
"homepage": "https://forgejo-notifications-core.docs.forgeflux.org/",
|
||||
"files": [
|
||||
"dist/",
|
||||
"dist/web.js",
|
||||
"dist/web.js.map",
|
||||
"package.json",
|
||||
"pnpm-lock.yaml"
|
||||
],
|
||||
|
@ -37,7 +37,7 @@
|
|||
},
|
||||
"name": "forgejo-notifications-core",
|
||||
"scripts": {
|
||||
"build": "spack",
|
||||
"build": "swc ./src/index.ts -o ./dist/index.js && spack --config ./spack.config.cjs",
|
||||
"lint": "prettier --write ./src/*",
|
||||
"test": "jest",
|
||||
"doc": "typedoc ./src/index.ts"
|
||||
|
|
8
spack.config.cjs
Normal file
8
spack.config.cjs
Normal file
|
@ -0,0 +1,8 @@
|
|||
module.exports = {
|
||||
entry: {
|
||||
web: __dirname + "/src/index.ts",
|
||||
},
|
||||
output: {
|
||||
path: __dirname + "/dist",
|
||||
},
|
||||
};
|
|
@ -57,6 +57,7 @@ class Forgejo {
|
|||
this.url.pathname = "/api/v1/user";
|
||||
let res = await fetch(this.url, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
headers: this.getTokenAuthHeader(),
|
||||
});
|
||||
return await res.json();
|
||||
|
@ -67,8 +68,11 @@ class Forgejo {
|
|||
*/
|
||||
async getNotifications(): Promise<Array<Notification>> {
|
||||
this.url.pathname = "/api/v1/notifications";
|
||||
this.url.pathname = "/api/v1/notifications";
|
||||
console.log(this.url);
|
||||
let res = await fetch(this.url, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
headers: this.getTokenAuthHeader(),
|
||||
});
|
||||
|
||||
|
@ -81,6 +85,7 @@ class Forgejo {
|
|||
this.url.pathname = "/api/v1/notifications/new";
|
||||
let res = await fetch(this.url, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
headers: this.getTokenAuthHeader(),
|
||||
});
|
||||
|
||||
|
@ -96,6 +101,7 @@ class Forgejo {
|
|||
this.url.pathname = `/api/v1/notifications/threads/${id}`;
|
||||
let res = await fetch(this.url, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
headers: this.getTokenAuthHeader(),
|
||||
});
|
||||
return await res.json();
|
||||
|
@ -179,6 +185,7 @@ class Forgejo {
|
|||
this.url.pathname = `/api/v1/repos/${owner}/${repo}/issues/${id}`;
|
||||
let res = await fetch(this.url, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
headers: this.getTokenAuthHeader(),
|
||||
});
|
||||
let issue = await res.json();
|
||||
|
@ -211,6 +218,7 @@ class Forgejo {
|
|||
this.url.pathname = `/api/v1/repos/${issue.repository.owner}/${issue.repository.name}/issues/${issue.number}/comments`;
|
||||
let res = await fetch(this.url, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
headers: this.getTokenAuthHeader(),
|
||||
});
|
||||
let c: Array<Comment> = await res.json();
|
||||
|
@ -235,3 +243,4 @@ class Forgejo {
|
|||
}
|
||||
|
||||
export default Forgejo;
|
||||
//export { Notification, Issue, Repository, Comment, User };
|
||||
|
|
Loading…
Reference in a new issue