Skip to content

Move Hardcoded Config Values to Config File #8

Description

@AviOfLagos

Move Hardcoded Values to Config File

Labels: good first issue, enhancement

Description

Currently, configuration values like PORT, MAX_TIMEOUT_MS, POLL_MS, etc. are hardcoded in server.js and adapter.js. This task is to move them to a config file that can be customized without editing code.

What You'll Learn

  • How to structure configuration in Node.js projects
  • Environment variable handling
  • Backward compatibility considerations

Requirements

  1. Create a config.js (or .env + dotenv) that exports:

    module.exports = {
      PORT: process.env.PORT || 3000,
      MAX_TIMEOUT_MS: parseInt(process.env.MAX_TIMEOUT_MS) || 180000,
      STABLE_INTERVAL_MS: parseInt(process.env.STABLE_INTERVAL_MS) || 30000,
      POLL_MS: parseInt(process.env.POLL_MS) || 500,
      SESSION_TIMEOUT_MS: parseInt(process.env.SESSION_TIMEOUT_MS) || 3600000,
      LARGE_PROMPT_THRESHOLD: parseInt(process.env.LARGE_PROMPT_THRESHOLD) || 15000
    };
  2. Update server.js to import and use these values

  3. Update adapter.js to import and use these values

  4. Add a .env.example file with documentation

  5. Update README.md with a "Configuration" section

Files to Create/Modify

  • config.js (new)
  • .env.example (new)
  • server.js (update to use config)
  • adapter.js (update to use config)
  • README.md (add Configuration section)
  • .gitignore (add .env if not already present)

Testing

# Test with default values
npm run dev

# Test with custom port
PORT=4000 npm run dev

Reference

See CLAUDE.md "Configuration values" section for all values to extract.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions