Skip to content

Commit

Permalink
most bugs fixed. You have to work now!
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwaves-ofc committed Jan 2, 2024
1 parent 4e33e66 commit b2c92d1
Show file tree
Hide file tree
Showing 41 changed files with 530 additions and 3,478 deletions.
593 changes: 486 additions & 107 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.1",
"description": "NodeJS Backend Structure.",
"main": "dist/index.js",
"preview": true,
"preview": false,
"homepage": "https://github.com/darkwaves-ofc/NodeJS-Backend-Structure",
"bugs": {
"url": "https://github.com/darkwaves-ofc/NodeJS-Backend-Structure/issues",
Expand Down Expand Up @@ -54,24 +54,24 @@
"license": "MIT",
"devDependencies": {
"@types/amqplib": "^0.10.4",
"@types/bcrypt": "^5.0.2",
"@types/circular-json": "^0.4.0",
"@types/cookie-parser": "^1.4.6",
"@types/ejs": "^3.1.5",
"@types/events": "^3.0.0",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20.10.6",
"@types/randomcolor": "^0.5.9",
"@types/ua-parser-js": "^0.7.39",
"@types/uuid": "^9.0.7",
"@types/ws": "^8.5.10",
"eslint": "^8.56.0",
"typescript": "^5.3.3",
"@types/events": "^3.0.0",
"discord.js": "^14.6.0",
"eslint": "^8.56.0",
"prettier": "^2.7.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"

"tslint-config-prettier": "^1.18.0",
"typescript": "^5.3.3"
},
"dependencies": {
"amqplib": "^0.10.3",
Expand Down
36 changes: 23 additions & 13 deletions src/handlers/loadincomingEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ interface Client {
}

interface WebSocketPath {
name: string;
run: (client: Client, socket: Socket, request: any) => void;
default: {
name: string;
run: (client: Client, socket: Socket, request: any) => void;
};
}

export = class WebSocketInitializer {
Expand All @@ -34,7 +36,7 @@ export = class WebSocketInitializer {

public async start() {
this.client.wsevents = new EventEmitter().setMaxListeners(
0,
0
) as EventEmitter;

const io = new socketIo.Server(this.client.server, {
Expand Down Expand Up @@ -68,27 +70,35 @@ export = class WebSocketInitializer {
next();
});

let versions = await new Promise<string[]>((resolve) => {
readdir("./src/websocket", (err, files) => {
resolve(files);
let versions: string[] = []; // Ensure versions is initialized as an array
try {
versions = await new Promise<string[]>((resolve) => {
readdir("./dist/websocket", (err, files) => {
if (err) {
console.error("Error reading directory:", err);
resolve([]); // Resolve with an empty array if there's an error
} else {
resolve(files);
}
});
});
});
} catch (error) {
console.error("Error getting versions:", error);
}

for (const version of versions) {
const websocketFiles = await new Promise<string[]>((resolve, reject) => {
readdir(`./src/websocket/${version}/`, (err, files) => {
readdir(`./dist/websocket/${version}/`, (err, files) => {
if (err) reject(err);
resolve(files?.filter((f) => f.endsWith(".js")) || []);
});
});

for (const file of websocketFiles) {
try {
const path: WebSocketPath = require(
`../websocket/${version}/${file}`,
);
if (path.name && typeof path.run === "function") {
this.client.wspaths.set(`/${version}${path.name}`, path);
const path: WebSocketPath = require(`../websocket/${version}/${file}`);
if (path.default.name && typeof path.default.run === "function") {
this.client.wspaths.set(`/${version}${path.default.name}`, path);
} else {
console.log(`Invalid module: ${file}`);
}
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/loadroutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ export = class RoutesInitializer {

public async start() {
let versions = await new Promise<string[]>((resolve) => {
readdir("./src/routes", (err, files) => {
readdir("./dist/routes", (err, files) => {
resolve(files);
});
});

for (const version of versions) {
const dirs = await new Promise<string[]>((resolve) => {
readdir(`./src/routes/${version}/`, (err, dirs) => {
readdir(`./dist/routes/${version}/`, (err, dirs) => {
resolve(dirs);
});
});

for (const dir of dirs) {
const webFiles = await new Promise<string[]>((resolve) => {
readdir(`./src/routes/${version}/${dir}/`, (err, files) => {
readdir(`./dist/routes/${version}/${dir}/`, (err, files) => {
resolve(files?.filter((f) => f.endsWith(".js")) || []);
});
});
Expand Down
Empty file removed src/routes/v1/broadcast/delete.js
Empty file.
58 changes: 0 additions & 58 deletions src/routes/v1/broadcast/get.js

This file was deleted.

42 changes: 0 additions & 42 deletions src/routes/v1/dashboard/delete.js

This file was deleted.

65 changes: 0 additions & 65 deletions src/routes/v1/dashboard/get.js

This file was deleted.

67 changes: 0 additions & 67 deletions src/routes/v1/dashboard/patch.js

This file was deleted.

Loading

0 comments on commit b2c92d1

Please sign in to comment.