Express Server Agent
1. Build & Development Commands: Project Setup:
Use npm install to install all dependencies specified in package.json.
Ensure the .env file is present in the project root with the GOOGLE_API_KEY environment variable set.
Running the Server:
Use node index.js or npm start to run the server.
Use nodemon index.js for development to enable automatic server restarts on file changes.
Dependency Management:
Add new dependencies using npm install <package-name> --save.
Remove dependencies using npm uninstall <package-name> --save.
Never alter package-lock.json manually.
Environment Variables:
All sensitive information, especially the Google Gemini API key, must be stored in the .env file.
Access environment variables using process.env.<VARIABLE_NAME>.
2. Testing Guidelines:
Unit Testing:
Implement unit tests for all core functions (e.g., generateResponse, startChat).
Use a testing framework like Jest or Mocha with Chai or Supertest.
Integration Testing:
Write integration tests to verify the behavior of API endpoints.
Test API endpoints with various input scenarios, including edge cases and error conditions.
API Testing:
Use Postman or curl to manually test API endpoints during development.
Verify that API responses are in the expected format and contain the correct data.
Error Handling:
Test error handling scenarios to ensure the server responds appropriately to invalid requests or API errors.
3. Code Style & Guidelines:
JavaScript Style:
Follow a consistent coding style (e.g., Airbnb JavaScript Style Guide).
Use ESLint to enforce code style and catch potential errors.
Use Prettier for automatic code formatting.
Code Organization:
Structure the codebase logically with separate files or modules for different functionalities.
Use comments to explain complex logic or non-obvious code sections.
Utilize Async/Await for asynchronous code.
Error Handling:
Implement robust error handling using try...catch blocks.
Log errors using Winston or a similar logging library.
Return meaningful error messages to the client.
Dependencies:
Use the dependencies listed in your package.json, and keep them updated.
Use Morgan for HTTP request logging.
Use lru-cache to cache frequent API requests.
Use Multer to handle multipart/form-data.
Use Body-parser to parse request bodies.
Use Node-fetch to make http requests.
Security:
Sanitize user inputs to prevent security vulnerabilities.
Implement proper authentication and authorization if necessary.
Use Cors to control which origins can access the API.
Documentation:
Document all API endpoints with clear descriptions of request parameters and response formats.
Document the server's setup and configuration.
No Docs configured
No Prompts configured
No Data configured
No MCP Servers configured