From f5fe8a90e5335fe8f6e5af9579f0fd369feada83 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Tue, 19 Sep 2023 05:24:43 +0530 Subject: [PATCH] fix: packaging --- package.json | 6 +++--- spack.config.cjs | 8 ++++++++ src/index.ts | 9 +++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 spack.config.cjs diff --git a/package.json b/package.json index b7ac474..82034ee 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/spack.config.cjs b/spack.config.cjs new file mode 100644 index 0000000..78d7f5e --- /dev/null +++ b/spack.config.cjs @@ -0,0 +1,8 @@ +module.exports = { + entry: { + web: __dirname + "/src/index.ts", + }, + output: { + path: __dirname + "/dist", + }, +}; diff --git a/src/index.ts b/src/index.ts index c26c0b3..4bfef7c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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> { 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 = await res.json(); @@ -235,3 +243,4 @@ class Forgejo { } export default Forgejo; +//export { Notification, Issue, Repository, Comment, User };