Spaces:
Paused
Paused
Update app.js
Browse files
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 =
|
16 |
-
|
17 |
-
|
18 |
-
|
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 || "
|
26 |
};
|
27 |
|
28 |
const STREMIO_API = {
|
@@ -67,8 +65,21 @@ app.use(session({
|
|
67 |
}
|
68 |
}));
|
69 |
|
70 |
-
//
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() {
|