Skip to content

Commit

Permalink
now using undici
Browse files Browse the repository at this point in the history
  • Loading branch information
Leref committed Jan 25, 2024
1 parent 55f5a67 commit c80abe6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 53 deletions.
62 changes: 17 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"body-parser": "^1.20.2",
"express": "^4.18.2",
"express-session": "^1.17.3",
"node-fetch": "^2.6.1"
"undici": "^6.4.0"
},
"devDependencies": {
"aoi.js": "^6.7.1"
Expand Down
2 changes: 1 addition & 1 deletion src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function loadAPIRoutes(data){
let app = data.app;
let auth=data.auth;
function checkAuth(req, res, next) {

if(!req.params.auth){
return res.status(401).json({"error":"No auth was provided."})
}
Expand Down
18 changes: 12 additions & 6 deletions src/utilFuncs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
const fetch = require("node-fetch");
const {AoiError} = require("aoi.js");
const { Agent, fetch } = require("undici");
const { AoiError } = require("aoi.js");
const json = require("../package.json");

async function checkVersion() {
try {
const res = await fetch("https://registry.npmjs.com/@akarui/aoi.panel");
const data = await res.json();
const agent = new Agent();
const response = await fetch("https://registry.npmjs.com/@akarui/aoi.panel", {
method: "GET",
agent,
});

const data = await response.json();
const c_version = json.version;

if (c_version.includes("dev")) {
Expand Down Expand Up @@ -63,10 +69,10 @@ function checkPackage() {
"red",
{ text: "@akarui/aoi.panel", textColor: "cyan" }
);
}
}
}

module.exports = {
checkVersion,
checkPackage
};
};

0 comments on commit c80abe6

Please sign in to comment.