2ccb018bdf
Players can create tours with selected courses/layouts and a date range. Others join via a 6-character tour code, play the courses, and report their total strokes. Live leaderboard with points and +/- par display. Includes: database schema, model, service, routes, views, and styling.
34 lines
952 B
JavaScript
34 lines
952 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 tourRoutes = require('./src/routes/tours');
|
|
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(tourRoutes);
|
|
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);
|
|
});
|