no1b4me commited on
Commit
697deee
·
verified ·
1 Parent(s): fbb51ee

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +21 -10
app.js CHANGED
@@ -12,17 +12,15 @@ const app = express();
12
  const port = process.env.PORT || 3001;
13
 
14
  // MongoDB connection setup
15
- const mongoUri = "mongodb+srv://mikmc55:vD6kL6jADy4Mxl5B@hy0.av11l.mongodb.net/?retryWrites=true&w=majority&appName=hy0";
16
- mongoose.connect(mongoUri, {
17
- useNewUrlParser: true,
18
- useUnifiedTopology: true,
19
- })
20
- .then(() => logger.info('Connected to MongoDB successfully'))
21
- .catch(err => logger.error('Failed to connect to MongoDB:', err));
22
 
23
  // Configuration and constants setup
24
  const config = {
25
- SESSION_SECRET: process.env.SESSION_SECRET || "bhdsaububsb387444nxkj"
26
  };
27
 
28
  const STREMIO_API = {
@@ -67,8 +65,21 @@ app.use(session({
67
  }
68
  }));
69
 
70
- // Routes and logic remain unchanged
71
- // Insert your existing routes and middleware here
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  // Server initialization
74
  async function startServer() {
 
12
  const port = process.env.PORT || 3001;
13
 
14
  // MongoDB connection setup
15
+ const mongoUri = process.env.MONGO_URI;
16
+
17
+ mongoose.connect(mongoUri)
18
+ .then(() => logger.info('Connected to MongoDB successfully'))
19
+ .catch(err => logger.error('Failed to connect to MongoDB:', err));
 
 
20
 
21
  // Configuration and constants setup
22
  const config = {
23
+ SESSION_SECRET: process.env.SESSION_SECRET || "default-session-secret"
24
  };
25
 
26
  const STREMIO_API = {
 
65
  }
66
  }));
67
 
68
+ // Hugging Face API Example Function
69
+ async function fetchHuggingFaceData(apiUrl) {
70
+ try {
71
+ const response = await fetch(apiUrl);
72
+ if (!response.ok) {
73
+ throw new Error(`HTTP Error: ${response.status}`);
74
+ }
75
+ const data = await response.json();
76
+ logger.info('Hugging Face API response:', data);
77
+ return data;
78
+ } catch (error) {
79
+ logger.error('Failed to fetch Hugging Face API:', error);
80
+ throw error;
81
+ }
82
+ }
83
 
84
  // Server initialization
85
  async function startServer() {