feat: Add cross-platform support with improved error handling and scripts

main
borja (aider) 3 months ago
parent b63c4cd2ec
commit d16823bbaf

@ -3,8 +3,15 @@
"module": "index.ts", "module": "index.ts",
"type": "module", "type": "module",
"private": true, "private": true,
"scripts": {
"start": "bun run src/index.ts",
"build": "tsc",
"dev": "bun --watch src/index.ts",
"test": "bun test"
},
"devDependencies": { "devDependencies": {
"@types/bun": "latest" "@types/bun": "latest",
"@types/node": "^20.11.19"
}, },
"peerDependencies": { "peerDependencies": {
"typescript": "^5" "typescript": "^5"
@ -13,6 +20,7 @@
"axios": "^1.8.4", "axios": "^1.8.4",
"better-sqlite3": "^11.9.1", "better-sqlite3": "^11.9.1",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"express": "^4.21.2" "express": "^4.21.2",
"cross-env": "^7.0.3"
} }
} }

@ -5,14 +5,34 @@ import { startServer } from './server/server';
// Load environment variables // Load environment variables
dotenv.config(); dotenv.config();
const PORT = 3000; // Get port from environment or default to 3000
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 3000;
// Start the bot and server // Start the bot and server
async function main() { async function main() {
try {
console.log('Starting bot...');
await startBot(); await startBot();
console.log('Bot started successfully');
console.log('Starting server...');
startServer(PORT); startServer(PORT);
console.log(`Server running on port ${PORT}`);
} catch (error) {
console.error('Error starting application:', error);
process.exit(1);
}
} }
main().catch((error) => { // Handle process termination
console.error('Error starting the bot:', error); process.on('SIGINT', () => {
console.log('Shutting down gracefully...');
process.exit(0);
});
process.on('SIGTERM', () => {
console.log('Shutting down gracefully...');
process.exit(0);
}); });
main();

Loading…
Cancel
Save