Skip to content

Commit 2e8f2a7

Browse files
committed
Update App.ts
1 parent 3394478 commit 2e8f2a7

File tree

1 file changed

+45
-28
lines changed

1 file changed

+45
-28
lines changed

src/structures/App.ts

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,54 @@
1-
import * as express from "express";
2-
import * as config from "../config";
3-
import * as cookieParser from "cookie-parser";
4-
import * as mongoose from "mongoose";
5-
import * as bodyParser from "body-parser";
6-
import * as amqp from "amqplib";
7-
import * as jwt from "jsonwebtoken";
8-
import * as userDataDb from "../schema/userData";
9-
import * as cors from "cors";
10-
import * as CircularJSON from "circular-json";
11-
import * as dayjs from "dayjs";
12-
import { EventEmitter } from "ws";
13-
import { v4 as uuidv4 } from "uuid";
14-
import { CompressionTypes, Partitioners } from "kafkajs";
15-
import "ejs";
16-
17-
class App extends express.Application {
1+
import express from "express";
2+
import config from "../config";
3+
import cookieParser from "cookie-parser";
4+
import mongoose from "mongoose";
5+
import bodyParser from "body-parser";
6+
import amqp from "amqplib";
7+
import jwt from "jsonwebtoken";
8+
import userDataDb from "../schema/userData";
9+
import cors from "cors";
10+
import getUserData from "../utils/getuserData.js";
11+
import Logger from "../utils/logger";
12+
// import * as CircularJSON from "circular-json";
13+
// import * as dayjs from "dayjs";
14+
// import { EventEmitter } from "ws";
15+
// import { v4 as uuidv4 } from "uuid";
16+
// import { CompressionTypes, Partitioners } from "kafkajs";
17+
18+
class App {
1819
private config: any;
1920
private express: any;
2021
private routes: Map<string, any>;
2122
private logger: any;
2223
private mongoose: any;
2324
private fileCache: Map<string, any>;
2425
private linkCache: Map<string, any>;
26+
private getUserData: any;
27+
private parseURL: any;
28+
private jwt: any;
29+
private ipport: any;
30+
private _errorMiddleware: any;
31+
private _requirehandlers: any;
32+
private port: any;
33+
private links: any;
34+
private server: any;
35+
private use: any;
36+
private listen: any;
37+
private set: any;
38+
private _router: any;
39+
private findUser: any;
40+
private connect: any;
2541

2642
constructor() {
27-
super();
43+
// super();
2844
this.config = config;
2945
this.express = express;
3046
this.routes = new Map();
31-
this.logger = require("../utils/logger.js");
47+
this.logger = Logger;
3248
this.mongoose = mongoose;
3349
this.fileCache = new Map();
3450
this.linkCache = new Map();
35-
this.getUserData = require("../utils/getuserData.js");
51+
this.getUserData = getUserData;
3652
this.mongoose.Promise = global.Promise;
3753

3854
this.mongoose.connection.on("connected", () => {
@@ -61,7 +77,7 @@ class App extends express.Application {
6177
this._errorMiddleware = async function (
6278
req: express.Request,
6379
res: express.Response,
64-
next: express.NextFunction,
80+
next: express.NextFunction
6581
) {
6682
return res.status(404).json({ error: true, message: "page not found" });
6783
};
@@ -75,13 +91,13 @@ class App extends express.Application {
7591
origin: this.config.website.fontendUri,
7692
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
7793
credentials: true,
78-
}),
94+
})
7995
);
8096
this.use(
8197
async (
8298
req: express.Request,
8399
res: express.Response,
84-
next: express.NextFunction,
100+
next: express.NextFunction
85101
) => {
86102
let checkHost = false;
87103

@@ -98,11 +114,11 @@ class App extends express.Application {
98114

99115
res.setHeader(
100116
"Access-Control-Allow-Headers",
101-
"Content-Type, Authorization",
117+
"Content-Type, Authorization"
102118
);
103119
res.setHeader("Access-Control-Allow-Private-Network", "true");
104120
next();
105-
},
121+
}
106122
);
107123

108124
this.use(cookieParser(this.config.website.secretKey));
@@ -123,7 +139,7 @@ class App extends express.Application {
123139
await new handler(this).start();
124140
}
125141

126-
this._router.stack.forEach((layer, index, layers) => {
142+
this._router.stack.forEach((layer: any, index: any, layers: any) => {
127143
if (layer.handle === this._errorMiddleware) {
128144
layers.splice(index, 1);
129145
}
@@ -153,7 +169,8 @@ class App extends express.Application {
153169
}
154170

155171
let data = await userDataDb.findOne({
156-
_id: decoded.uuid,
172+
// _id: decoded.uuid,
173+
_id: decoded,
157174
});
158175

159176
if (!data) {
@@ -162,7 +179,7 @@ class App extends express.Application {
162179
}
163180

164181
const tokenSchema = data.tokens.find(
165-
(val: any) => val.token === token,
182+
(val: any) => val.token === token
166183
);
167184

168185
if (!tokenSchema) {

0 commit comments

Comments
 (0)