6ac32457a9
Replace all console.log/error with Pino logger (info/warn/error/debug/fatal) for structured JSON logging in production and pretty-print in development. Remove redundant header dumps and consolidate rate-limit logging. Add GitHub Actions workflow with release-please for automated semver releases and Docker build/push to GHCR on new releases.
32 lines
881 B
JavaScript
32 lines
881 B
JavaScript
const express = require('express');
|
|
const path = require('path');
|
|
|
|
const { initializeDatabase, checkAndPopulateDatabase } = require('./src/db');
|
|
const playerRoutes = require('./src/routes/players');
|
|
const courseRoutes = require('./src/routes/courses');
|
|
const pageRoutes = require('./src/routes/pages');
|
|
const logger = require('./src/logger');
|
|
|
|
const app = express();
|
|
const PORT = 3000;
|
|
|
|
app.set('view engine', 'ejs');
|
|
app.set('views', path.join(__dirname, 'views/pages'));
|
|
app.use(express.static('public'));
|
|
app.use(express.json());
|
|
|
|
app.use(playerRoutes);
|
|
app.use(courseRoutes);
|
|
app.use(pageRoutes);
|
|
|
|
initializeDatabase().then(async () => {
|
|
await checkAndPopulateDatabase();
|
|
|
|
app.listen(PORT, () => {
|
|
logger.info(`PDGA Ratings app running on http://localhost:${PORT}`);
|
|
});
|
|
}).catch(err => {
|
|
logger.fatal('Failed to initialize database:', err);
|
|
process.exit(1);
|
|
});
|