feat(config): add configurable check-in date restriction and persistent logging

- Add ENABLE_CHECKIN_DATE_RESTRICTION environment variable to allow flexible check-in testing
- Replace NODE_ENV check with configurable flag in check-in validation logic
- Implement persistent logging with external Docker volumes (slc_logs_prod)
- Configure backend-prod and nginx-prod to write logs to /var/log/app/ and /var/log/nginx-app/
- Increase log rotation limits (50MB, 10 files) for better debugging
- Update .env.example files with new check-in configuration
This commit is contained in:
Radosław Gierwiało
2025-12-06 18:24:16 +01:00
parent 1ff70a9f7f
commit 819ac3a49b
4 changed files with 25 additions and 8 deletions

View File

@@ -71,3 +71,8 @@ CLOUDFLARE_TURN_API_TOKEN=your-turn-api-token-here
# Beta Testing # Beta Testing
# Auto-assign SUPPORTER tier to new registrations during beta # Auto-assign SUPPORTER tier to new registrations during beta
BETA_AUTO_SUPPORTER=false BETA_AUTO_SUPPORTER=false
# Event Check-in
# Enable date restriction for check-in (event dates ±1 day)
# Set to 'false' for testing or events where QR code access is controlled manually
ENABLE_CHECKIN_DATE_RESTRICTION=false

View File

@@ -71,3 +71,8 @@ CLOUDFLARE_TURN_API_TOKEN=your-production-turn-api-token-here
# Beta Testing # Beta Testing
# Auto-assign SUPPORTER tier to new registrations during beta # Auto-assign SUPPORTER tier to new registrations during beta
BETA_AUTO_SUPPORTER=false BETA_AUTO_SUPPORTER=false
# Event Check-in
# Enable date restriction for check-in (event dates ±1 day)
# Set to 'false' for testing or events where QR code access is controlled manually
ENABLE_CHECKIN_DATE_RESTRICTION=false

View File

@@ -239,9 +239,9 @@ router.post('/checkin/:token', authenticate, async (req, res, next) => {
const event = checkinToken.event; const event = checkinToken.event;
// Validate dates (only in production) // Validate dates (only if date restriction is enabled)
const isProduction = process.env.NODE_ENV === 'production'; const enableDateRestriction = process.env.ENABLE_CHECKIN_DATE_RESTRICTION === 'true';
if (isProduction) { if (enableDateRestriction) {
const now = new Date(); const now = new Date();
const validFrom = new Date(event.startDate); const validFrom = new Date(event.startDate);
validFrom.setDate(validFrom.getDate() - 1); validFrom.setDate(validFrom.getDate() - 1);

View File

@@ -34,15 +34,17 @@ services:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/conf.d.prod:/etc/nginx/conf.d:ro - ./nginx/conf.d.prod:/etc/nginx/conf.d:ro
- ./ssl:/etc/nginx/ssl:ro - ./ssl:/etc/nginx/ssl:ro
- app_logs_prod:/var/log/nginx-app
ports: ports:
- "80:80" - "80:80"
- "443:443" - "443:443"
restart: always restart: always
command: ["/bin/sh", "-c", "nginx -g 'daemon off;' 2>&1 | tee -a /var/log/nginx-app/nginx.log"]
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
max-size: "10m" max-size: "50m"
max-file: "3" max-file: "10"
deploy: deploy:
resources: resources:
limits: limits:
@@ -175,13 +177,15 @@ services:
- LOG_LEVEL=warn - LOG_LEVEL=warn
depends_on: depends_on:
- db-prod - db-prod
command: ["node", "src/server.js"] command: ["sh", "-c", "node src/server.js 2>&1 | tee -a /var/log/app/backend.log"]
restart: always restart: always
volumes:
- app_logs_prod:/var/log/app
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
max-size: "10m" max-size: "50m"
max-file: "3" max-file: "10"
deploy: deploy:
resources: resources:
limits: limits:
@@ -248,6 +252,9 @@ volumes:
postgres_data_prod: postgres_data_prod:
external: true external: true
name: slc_postgres_prod_data name: slc_postgres_prod_data
app_logs_prod:
external: true
name: slc_logs_prod
networks: networks:
slc_network: slc_network: