mirror of
https://github.com/MasterAcnolo/Quick-API.git
synced 2026-07-29 18:05:46 +02:00
48 lines
1.3 KiB
JavaScript
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;
|