Compare commits

...

2 Commits

Author SHA1 Message Date
Aravinth Manivannan f5fe8a90e5
fix: packaging
ci/woodpecker/push/woodpecker Pipeline was successful Details
2023-09-19 05:24:43 +05:30
Aravinth Manivannan fa1d7427ab
feat: setup packaging 2023-09-19 04:10:21 +05:30
3 changed files with 54 additions and 7 deletions

View File

@ -1,17 +1,47 @@
{
"author": "Aravinth Manivannan <realaravinth@batsense.net>",
"description": "JS library to interact with Forgejo API to work with notification",
"version": "0.1.0-alpha-1",
"license": "AGPL-3.0-or-later",
"type": "module",
"module": "dist/web.js",
"main": "dist/web.js",
"keywords": [
"Forgejo",
"ForgeFlux"
],
"homepage": "https://forgejo-notifications-core.docs.forgeflux.org/",
"files": [
"dist/web.js",
"dist/web.js.map",
"package.json",
"pnpm-lock.yaml"
],
"bugs": {
"url": "https://git.batsense.net/realaravinth/forgejo-notifications-core/issues",
"email": "realaravinth@batsense.net"
},
"funding": [
{
"type": "individual",
"url": "http://batsense.net/donate"
},
{
"type": "liberapay",
"url": "https://liberapay.com/realaravinth"
}
],
"repository": {
"type": "git",
"url": "https://git.batsense.net/realaravinth/forgejo-notifications-core/"
},
"name": "forgejo-notifications-core",
"version": "1.0.0",
"description": "",
"main": "index.js",
"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"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@jest/globals": "^29.7.0",
"@swc/cli": "^0.1.62",

8
spack.config.cjs Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
entry: {
web: __dirname + "/src/index.ts",
},
output: {
path: __dirname + "/dist",
},
};

View File

@ -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 };