export default function generateReadmeContent(response) {
const { projectName, database, additionalFeatures, useDocker } = response;
let content = `
${projectName}
This is a Node.js Express API project generated with a custom project initializer.
Project Structure
```
${projectName}/
├── src/
│ ├── config/
│ ├── controllers/
│ ├── middleware/
│ ├── models/
│ ├── routes/
│ ├── utils/
│ ├── app.ts
│ └── server.ts
├── tests/
├── .env
├── .gitignore
├── package.json
├── tsconfig.json
${useDocker ? '├── Dockerfile\n├── docker-compose.yml' : ''}
└── README.md
```
Features
- Express.js framework
- TypeScript support
- Environment configuration with dotenv
${database !== 'none' ?
- ${database} database integration : ''}
${additionalFeatures.includes('auth') ? '- JWT Authentication' : ''}
${additionalFeatures.includes('errorHandling') ? '- Custom error handling' : ''}
${additionalFeatures.includes('logging') ? '- Logging with Winston' : ''}
${additionalFeatures.includes('swagger') ? '- API documentation with Swagger' : ''}
${additionalFeatures.includes('rateLimit') ? '- Rate limiting' : ''}
${additionalFeatures.includes('compression') ? '- Response compression' : ''}
${additionalFeatures.includes('cors') ? '- CORS enabled' : ''}
${additionalFeatures.includes('helmet') ? '- Security headers with Helmet' : ''}
${useDocker ? '- Docker support' : ''}
Prerequisites
- Node.js (version 14 or later recommended)
- npm (comes with Node.js)
${database === 'mongodb' ? '- MongoDB' : ''}
${database === 'postgresql' ? '- PostgreSQL' : ''}
${database === 'mysql' ? '- MySQL' : ''}
${useDocker ? '- Docker and Docker Compose (for containerization)' : ''}
Getting Started
-
Clone the repository:
```
git clone https://github.com/yourusername/${projectName}.git
cd ${projectName}
```
-
Install dependencies:
```
npm install
```
-
Set up your environment variables:
Copy the `.env.example` file to `.env` and update the values as needed.
-
Start the development server:
```
npm run dev
```
${useDocker ? `
Running with Docker
The API will be available at `http://localhost:3000\`.
` : ''}
Available Scripts
- `npm run dev`: Start the development server with hot-reloading
- `npm run build`: Build the TypeScript code
- `npm start`: Start the production server
- `npm test`: Run the test suite
API Documentation
${additionalFeatures.includes('swagger') ? 'API documentation is available at /api-docs when the server is running.' : 'API documentation is not set up for this project.'}
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
License
This project is licensed under the ISC License - see the LICENSE.md file for details.
`;
return content.trim();
}