Public Access
feat: implement Docker containerization, Gitea release pipeline, and express server entry point
Release Pipeline / build-and-release (push) Failing after 13s
Release Pipeline / build-and-release (push) Failing after 13s
This commit is contained in:
1 parent
53abe32795
commit
ad0fec5005
4 files changed
+129
No files matched your search
@@ -5,6 +5,12 @@ import authRoutes from './routes/auth.js'
|
||||
import examRoutes from './routes/exams.js'
|
||||
import resultRoutes from './routes/results.js'
|
||||
import adminRoutes from './routes/admin.js'
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
|
||||
const PORT = Number(process.env['PORT'] ?? '3001')
|
||||
|
||||
@@ -28,6 +34,22 @@ app.get('/api/health', (_req, res) => {
|
||||
res.json({ status: 'ok', timestamp: Date.now() })
|
||||
})
|
||||
|
||||
// Serve static frontend files if they exist
|
||||
const frontendDistPath = path.join(__dirname, '../../frontend/dist')
|
||||
if (fs.existsSync(frontendDistPath)) {
|
||||
console.log(`Serving frontend from: ${frontendDistPath}`)
|
||||
app.use(express.static(frontendDistPath))
|
||||
app.get('*', (req, res) => {
|
||||
if (!req.path.startsWith('/api')) {
|
||||
res.sendFile(path.join(frontendDistPath, 'index.html'))
|
||||
} else {
|
||||
res.status(404).json({ error: 'API route not found' })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log('Frontend build not found, skipping static serving.')
|
||||
}
|
||||
|
||||
const server = app.listen(PORT, () => {
|
||||
console.log(`🧠 BrainWave API running on http://localhost:${PORT}`)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user