Files
Quick-API/src/config/config.js
MasterAcnolo 1a5a7fa7e1 feat: initial release of Quick API
Express server that automatically generates REST endpoints from JSON files.
2026-05-30 23:20:25 +02:00

48 lines
1.3 KiB
JavaScript

/**
* @file config/config.js
* @description Centralized configuration for Quick API.
* All configurable values live here.
* Environment variables take priority over defaults.
*
* Supported environment variables:
* PORT - Listening port (default: 3000)
* DATA_DIR - Path to the JSON files (default: ./data)
* BODY_LIMIT - Maximum request body size (default: 10mb)
* LOG_ENABLED - Enable HTTP request logging (default: true)
*/
'use strict';
const path = require('path');
const config = {
/** Server listening port */
port: parseInt(process.env.PORT || '3000', 10),
/** Directory containing the JSON files to expose */
dataDir: process.env.DATA_DIR
? path.resolve(process.env.DATA_DIR)
: path.resolve(__dirname, '../../data'),
/** Maximum request body size for POST requests */
bodyLimit: process.env.BODY_LIMIT || '10mb',
/** Enable HTTP request logging */
logEnabled: process.env.LOG_ENABLED !== 'false',
/** CORS configuration */
cors: {
origin: '*',
exposedHeaders: ['X-Total-Count', 'X-Page', 'X-Limit'],
},
/** Default pagination values */
pagination: {
defaultPage: 1,
defaultLimit: 0, // 0 = no limit (returns all records)
maxLimit: 500, // safety cap to avoid oversized responses
},
};
module.exports = config;