randydev commited on
Commit
b45d8e6
·
verified ·
1 Parent(s): f8d4c3d

Update startup/lifestyle.js

Browse files
Files changed (1) hide show
  1. startup/lifestyle.js +16 -2
startup/lifestyle.js CHANGED
@@ -10,8 +10,21 @@ const port = 7860
10
 
11
  const startup = async () => {
12
  try {
13
- mongoose.connect(`mongodb+srv://${UsernameDB}:${PasswordDB}@cluster0.1asx6h1.mongodb.net/AkenoXJs?retryWrites=true&w=majority`);
14
- console.log("Mongoose connected successful.");
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  const dbClient = new Database("AkenoXJs");
16
  console.log("Starting application...");
17
  await dbClient.connect();
@@ -22,6 +35,7 @@ const startup = async () => {
22
  }
23
  };
24
 
 
25
  const startServer = async (app) => {
26
  await startup();
27
  app.listen(port, "0.0.0.0", () => {
 
10
 
11
  const startup = async () => {
12
  try {
13
+ await mongoose.connect(`mongodb+srv://${UsernameDB}:${PasswordDB}@cluster0.1asx6h1.mongodb.net/AkenoXJs?retryWrites=true&w=majority`);
14
+ console.log("Mongoose connected successfully.");
15
+
16
+ const collection = mongoose.connection.collection("ApiKey");
17
+ try {
18
+ await collection.dropIndex("expiresAt_1");
19
+ console.log("Dropped TTL index on expiresAt.");
20
+ } catch (err) {
21
+ if (err.codeName === "IndexNotFound") {
22
+ console.log("No TTL index found, skipping dropIndex.");
23
+ } else {
24
+ console.error("Error dropping index:", err.message);
25
+ }
26
+ }
27
+
28
  const dbClient = new Database("AkenoXJs");
29
  console.log("Starting application...");
30
  await dbClient.connect();
 
35
  }
36
  };
37
 
38
+
39
  const startServer = async (app) => {
40
  await startup();
41
  app.listen(port, "0.0.0.0", () => {