Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #63

Merged
merged 3 commits into from
Mar 24, 2024
Merged

Dev #63

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ app.use(passport.initialize());
app.use(passport.session());



// Periodically attempt to reconnect every 10 minutes
cron.schedule('*/10 * * * *', async () => {
console.log('Attempting to reconnect to the database...');
Expand All @@ -69,6 +70,20 @@ app.use(attachPendingRequestCount);
app.use(attachPendingBetsCount);
app.use(setAdminStatus);

// Set up rate limiter: maximum of 100 requests per 15 minutes
var RateLimit = require('express-rate-limit');
var limiter = RateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 250, // max 100 requests per windowMs
});


app.set('view engine', 'ejs');
app.use(express.static('public'));

// Apply rate limiter to all requests
app.use(limiter);

app.use(require('./routes/auth'));
app.use(require('./routes/index'));
app.use(isAuthenticated, require('./routes/dashboard'));
Expand All @@ -78,8 +93,7 @@ app.use('/bak', isAuthenticated, require('./routes/bak'));
app.use('/bak-getrokken', isAuthenticated, require('./routes/bakGetrokken'));
app.use('/admin', isAuthenticated, isAdmin, require('./routes/admin'));

app.set('view engine', 'ejs');
app.use(express.static('public'));


app.use(function (req, res, next) {
res.status(404).render('error/404');
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dotenv": "^16.4.5",
"ejs": "^3.1.9",
"express": "^4.18.3",
"express-rate-limit": "^7.2.0",
"express-session": "^1.18.0",
"lusca": "^1.7.0",
"mssql": "^10.0.2",
Expand Down
3 changes: 2 additions & 1 deletion routes/bak.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ router.post('/submit', async (req, res) => {

res.redirect('/dashboard');
} catch (error) {
res.status(500).send(error.message);
console.error(error.message); // Log the error on the server
res.status(500).send('An error occurred'); // Send a generic error message to the client
}
});

Expand Down
Loading