Spaces:
Paused
Paused
Deploy Bot commited on
Commit ·
4961765
1
Parent(s): 348ef29
Fix SyntaxError in main.js: duplicate bot declaration
Browse files- src/main.js +9 -5
src/main.js
CHANGED
|
@@ -19,11 +19,9 @@ const app = express();
|
|
| 19 |
app.use(cors());
|
| 20 |
app.use(bodyParser.json());
|
| 21 |
// Inject Bot into Request
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
next();
|
| 26 |
-
});
|
| 27 |
app.use('/api', apiRoutes);
|
| 28 |
app.use('/public', express.static(path.join(__dirname, '../public'))); // Serve Static Files (APK, etc.)
|
| 29 |
|
|
@@ -49,6 +47,12 @@ const bot = new Telegraf(config.BOT_TOKEN, {
|
|
| 49 |
telegram: { agent: telegramAgent }
|
| 50 |
});
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
module.exports = bot; // Export bot instance
|
| 53 |
|
| 54 |
|
|
|
|
| 19 |
app.use(cors());
|
| 20 |
app.use(bodyParser.json());
|
| 21 |
// Inject Bot into Request
|
| 22 |
+
// Inject Bot into Request (Moved below)
|
| 23 |
+
// const bot = require('../main'); // CIRCULAR DEPENDENCY & ERROR
|
| 24 |
+
// app.use((req, res, next) => { ... });
|
|
|
|
|
|
|
| 25 |
app.use('/api', apiRoutes);
|
| 26 |
app.use('/public', express.static(path.join(__dirname, '../public'))); // Serve Static Files (APK, etc.)
|
| 27 |
|
|
|
|
| 47 |
telegram: { agent: telegramAgent }
|
| 48 |
});
|
| 49 |
|
| 50 |
+
// Inject Bot into Request (Fixed)
|
| 51 |
+
app.use((req, res, next) => {
|
| 52 |
+
req.bot = bot;
|
| 53 |
+
next();
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
module.exports = bot; // Export bot instance
|
| 57 |
|
| 58 |
|