2025-12-19 20:44:46 -06:00
|
|
|
const path = require("path");
|
|
|
|
|
|
|
|
|
|
const ENVIRONMENTS = {
|
|
|
|
|
DEVELOPMENT: "development",
|
|
|
|
|
PRODUCTION: "production",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const HTTP_STATUS = {
|
|
|
|
|
OK: 200,
|
|
|
|
|
CREATED: 201,
|
|
|
|
|
BAD_REQUEST: 400,
|
|
|
|
|
UNAUTHORIZED: 401,
|
|
|
|
|
FORBIDDEN: 403,
|
|
|
|
|
NOT_FOUND: 404,
|
|
|
|
|
CONFLICT: 409,
|
|
|
|
|
TOO_MANY_REQUESTS: 429,
|
|
|
|
|
INTERNAL_ERROR: 500,
|
|
|
|
|
SERVICE_UNAVAILABLE: 503,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const RATE_LIMITS = {
|
|
|
|
|
API: {
|
|
|
|
|
windowMs: 15 * 60 * 1000, // 15 minutes
|
2026-01-18 02:22:05 -06:00
|
|
|
max: 1000, // Increased for production - 1000 requests per 15 minutes per IP
|
2025-12-19 20:44:46 -06:00
|
|
|
},
|
|
|
|
|
AUTH: {
|
2025-12-24 00:13:23 -06:00
|
|
|
windowMs: 15 * 60 * 1000, // 15 minutes
|
2026-01-18 02:22:05 -06:00
|
|
|
max: 5, // 5 failed attempts before lockout (successful requests are skipped)
|
2025-12-19 20:44:46 -06:00
|
|
|
},
|
|
|
|
|
UPLOAD: {
|
|
|
|
|
windowMs: 60 * 60 * 1000, // 1 hour
|
2026-01-18 02:22:05 -06:00
|
|
|
max: 100, // Increased for production
|
2025-12-19 20:44:46 -06:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const SESSION_CONFIG = {
|
|
|
|
|
COOKIE_MAX_AGE: 24 * 60 * 60 * 1000, // 24 hours
|
|
|
|
|
SESSION_NAME: "skyartshop.sid",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const BODY_PARSER_LIMITS = {
|
|
|
|
|
JSON: "10mb",
|
|
|
|
|
URLENCODED: "10mb",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const isDevelopment = () => process.env.NODE_ENV !== ENVIRONMENTS.PRODUCTION;
|
|
|
|
|
|
|
|
|
|
const getBaseDir = () =>
|
|
|
|
|
isDevelopment()
|
|
|
|
|
? path.join(__dirname, "..", "..", "website")
|
|
|
|
|
: "/var/www/skyartshop";
|
|
|
|
|
|
|
|
|
|
const CRITICAL_IMAGES = [
|
|
|
|
|
"/assets/images/hero-image.jpg",
|
|
|
|
|
"/assets/images/products/placeholder.jpg",
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const STATIC_ASSET_EXTENSIONS =
|
|
|
|
|
/\.(jpg|jpeg|png|gif|svg|css|js|ico|webp|woff|woff2|ttf|eot)$/i;
|
|
|
|
|
|
|
|
|
|
const PG_ERROR_CODES = {
|
|
|
|
|
UNIQUE_VIOLATION: "23505",
|
|
|
|
|
FOREIGN_KEY_VIOLATION: "23503",
|
|
|
|
|
INVALID_TEXT: "22P02",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const MULTER_ERROR_CODES = {
|
|
|
|
|
FILE_SIZE: "LIMIT_FILE_SIZE",
|
|
|
|
|
FILE_COUNT: "LIMIT_FILE_COUNT",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
ENVIRONMENTS,
|
|
|
|
|
HTTP_STATUS,
|
|
|
|
|
RATE_LIMITS,
|
|
|
|
|
SESSION_CONFIG,
|
|
|
|
|
BODY_PARSER_LIMITS,
|
|
|
|
|
CRITICAL_IMAGES,
|
|
|
|
|
STATIC_ASSET_EXTENSIONS,
|
|
|
|
|
PG_ERROR_CODES,
|
|
|
|
|
MULTER_ERROR_CODES,
|
|
|
|
|
isDevelopment,
|
|
|
|
|
getBaseDir,
|
|
|
|
|
};
|