Prototype app made by google ai studio
This commit is contained in:
commit
f0ad8481c4
51 files changed
+12777
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import path from 'path';
|
||||
import dotenv from 'dotenv';
|
||||
import authRoutes from './src/server/routes/authRoutes';
|
||||
import roundsRoutes from './src/server/routes/roundsRoutes';
|
||||
import communityRoutes from './src/server/routes/communityRoutes';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const app = express();
|
||||
const PORT = 3000;
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
// Body parsers
|
||||
app.use(express.json({ limit: '10mb' }));
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
|
||||
// Health check endpoint
|
||||
app.get('/healthz', (_req: Request, res: Response) => {
|
||||
res.status(200).send('healthy\n');
|
||||
});
|
||||
|
||||
// API Routes
|
||||
app.use('/api/auth', authRoutes);
|
||||
app.use('/api/rounds', roundsRoutes);
|
||||
app.use('/api/community', communityRoutes);
|
||||
|
||||
async function startServer() {
|
||||
if (!isProduction) {
|
||||
// Development mode: Vite middleware
|
||||
const { createServer: createViteServer } = await import('vite');
|
||||
const vite = await createViteServer({
|
||||
server: {
|
||||
middlewareMode: true,
|
||||
hmr: process.env.DISABLE_HMR !== 'true',
|
||||
watch: process.env.DISABLE_HMR === 'true' ? null : {},
|
||||
},
|
||||
appType: 'spa',
|
||||
});
|
||||
app.use(vite.middlewares);
|
||||
} else {
|
||||
// Production mode: Serve static build assets
|
||||
const distPath = path.resolve(process.cwd(), 'dist');
|
||||
app.use(express.static(distPath));
|
||||
app.get('*', (_req: Request, res: Response) => {
|
||||
res.sendFile(path.join(distPath, 'index.html'));
|
||||
});
|
||||
}
|
||||
|
||||
app.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`🏌️♂️ PinPoint Golf full-stack server running on http://0.0.0.0:${PORT}`);
|
||||
});
|
||||
}
|
||||
|
||||
startServer().catch((err) => {
|
||||
console.error('Failed to start server:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in new issue
Block a user