mirror of
https://github.com/MasterAcnolo/Quick-API.git
synced 2026-07-30 02:05:48 +02:00
feat: initial release of Quick API
Express server that automatically generates REST endpoints from JSON files.
This commit is contained in:
47
src/config/config.js
Normal file
47
src/config/config.js
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @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;
|
||||
Reference in New Issue
Block a user