depsite
v1.0.1
Published
A TypeScript CLI tool that automates the deployment of nginx reverse proxy configurations for Node.js applications
Maintainers
Readme
DepSite - Nginx Site Deployment Tool
A TypeScript CLI tool that automates the deployment of nginx reverse proxy configurations for Node.js applications.
Features
- 🚀 Interactive CLI with colored output
- 🔧 Automatic nginx configuration generation
- 🔒 SSL certificate setup with Certbot
- ✅ Configuration validation and testing
- 🔄 Automatic rollback on failure
- 📝 Comprehensive deployment summary
Prerequisites
- Node.js (>=14.0.0)
- Nginx installed and running
- Certbot (optional, for SSL setup)
- Sudo privileges for nginx configuration
Quick Start
# Install globally
npm install -g depsite
# Deploy a site
depsite
# Remove a site
depsite remove my-project
# Show help
depsite --helpInstallation
# Clone or download the project
cd ~/Desktop/Code/NodeJs/depsite
# Install dependencies
yarn install
# Build the project
yarn buildUsage
Development Mode
yarn devProduction Mode
# Build first
yarn build
# Run the built version
yarn startWhat it does
- Validates Environment: Checks for nginx installation and sudo privileges
- Collects Input: Prompts for project name, domain, and port number
- Generates Configuration: Creates nginx upstream and server blocks
- Validates Setup: Tests nginx configuration before applying
- Enables Site: Creates symbolic links in sites-enabled
- SSL Setup: Optionally configures SSL certificates with Certbot
- Provides Summary: Shows deployment details and useful commands
Example nginx Configuration Generated
# Upstream for my-app Production
upstream my-app_prod {
ip_hash;
server 127.0.0.1:3000;
}
# HTTP Server Block
server {
listen 80;
server_name my-app.example.com;
client_max_body_size 20M;
charset utf-8;
# Custom error pages
error_page 404 /not-found;
error_page 500 502 503 504 /bad-request;
location / {
proxy_pass http://my-app_prod;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
}
}Project Structure
depsite/
├── src/
│ └── index.ts # Main application file
├── dist/ # Compiled JavaScript (after build)
├── package.json # Project configuration
├── tsconfig.json # TypeScript configuration
└── README.md # This fileError Handling
- Automatic rollback on configuration errors
- Validation of user input
- Dependency checking
- Graceful error messages with colored output
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
MIT License - see LICENSE file for details
