Files
Jellystat/backend/server.js
Thegan Govender dc3f900c5a users page + db auto create(WIP)
Created users info page when viewing user data on user tab

Added DB Procs to retrieve data for those components

Added db auto initialize to the backend in preparation for docker images, this needs work as it still crashes if it cant connect to the db
2023-03-23 22:37:04 +02:00

34 lines
869 B
JavaScript

// server.js
const express = require('express');
const cors = require('cors');
const apiRouter = require('./api');
const syncRouter = require('./sync');
const statsRouter = require('./stats');
const ActivityMonitor=require('./watchdog/ActivityMonitor');
const db = require("./db");
const app = express();
const PORT = process.env.PORT || 3003;
const LISTEN_IP = '127.0.0.1';
app.use(express.json()); // middleware to parse JSON request bodies
app.use(cors());
app.use('/api', apiRouter); // mount the API router at /api
app.use('/sync', syncRouter); // mount the API router at /sync
app.use('/stats', statsRouter); // mount the API router at /stats
app.listen(PORT, () => {
console.log(`Server listening on http://${LISTEN_IP}:${PORT}`);
try{
db.initDB();
ActivityMonitor.ActivityMonitor(1000);
}catch(error)
{
console.log(error);
}
});