Test Environment for XyNginC Plugin
This project is created in order to test the xynginc plugin in a real environment. You may need to buy a VPS and host this into your VPS. Clone it from my GitHub: https://github.com/iDevo-ll/XYNC-Demo.git
This demonstration project showcases the XyNginC plugin in a realistic production-like environment, perfect for testing its features on a live VPS setup with Nginx reverse proxy and SSL certificate management.
This test project demonstrates:
- Production Environment Testing: Real-world deployment scenarios with Nginx and SSL
- VPS Hosting: Optimized for virtual private server deployments
- XyNginC Integration: Full integration with the XyNginC plugin for automated reverse proxy setup
- SSL Management: Automatic Let's Encrypt certificate generation and renewal
-
Clone the repository on your VPS:
git clone https://github.com/iDevo-ll/XYNC-Demo.git cd XYNC-Demo -
Install dependencies:
npm install
-
Configure your domain:
- Update domain configuration in
src/configs/xypriss.config.ts - Set up DNS A record pointing to your VPS IP address
- Update domain configuration in
-
Start with XyNginC:
sudo npm start
The XyNginC plugin will automatically:
- Configure Nginx reverse proxy
- Set up SSL certificates via Let's Encrypt
- Enable automatic HTTPS
- Manage domain routing
# Install dependencies
npm install
# Start development server with hot reload
npm run devThe server will start on http://localhost:9837 with hot reload and TypeScript compilation enabled.
# Build for production
npm run build
# Start production server
npm startβββ src/
β βββ server.ts # Main server entry point
β βββ _sys/ # System configuration
β βββ configs/ # Server configuration
β βββ middleware/ # Custom middleware
β βββ routes/ # API routes
β βββ schema/ # Validation schemas
βββ package.json # Dependencies and scripts
βββ quickdev.config.json # Development server config
βββ xypriss.config.json # XyPriss framework config
βββ tsconfig.json # TypeScript configuration
- π Authentication - JWT-based authentication
- π File Upload - Support for file uploads
- Type Safety: Full TypeScript support with strict type checking
- High Performance: Built on XyPriss framework with optimized performance
- Hot Reload: Development server with automatic reloading and TypeScript compilation
- Security: Built-in security middleware and protections
- Validation: Request validation with Fortify Schema and TypeScript types
- File Upload: Support for multipart file uploads with type safety
- Caching: Memory-based caching for improved performance
- π Nginx Integration: Automatic reverse proxy configuration via XyNginC plugin
- π SSL/HTTPS: Automatic SSL certificate management with Let's Encrypt
This demo project showcases the XyNginC plugin in action. The server configuration includes:
import { createServer } from "xypriss";
import XNCP from "xynginc";
const app = createServer({
plugins: {
register: [
XNCP({
domains: [
{
domain: "your-domain.com", // Replace with your domain
port: 9837,
ssl: true,
email: "admin@your-domain.com", // Replace with your email
},
],
}),
],
},
});To run this demo on a VPS, ensure you have:
- Linux VPS (Ubuntu/Debian recommended)
- Root access or sudo privileges
- Domain name with DNS pointing to your VPS IP
- Ports 80 and 443 open for HTTP/HTTPS traffic
On your VPS, install the required software:
# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js 18+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install Nginx
sudo apt install nginx -y
# Install Certbot for SSL
sudo apt install certbot python3-certbot-nginx -y
# Install PM2 for process management
sudo npm install -g pm2GET /health- Server health statusGET /api/status- API status information
GET /api/users- List usersPOST /api/users- Create user
POST /api/upload- Upload files
POST /api/validate- Validate input data
Create a .env file in the root directory:
PORT=9837
NODE_ENV=production
DOMAIN=your-domain.com
SSL_EMAIL=admin@your-domain.comEdit src/configs/xypriss.config.ts to customize:
- Server port and host
- Security settings
- Performance options
- File upload limits
- Caching configuration
- XyNginC domain settings for production deployment
Important: This demo uses test domains provided by the Nehonix team. You must replace these with your own domains for production deployment:
/**
* These domains are test domains provided by nehonix team
* You would need to replace it with your own domain
*/
{
id: "server.nehonix.xyz", // β Replace with your domain
port: 9283,
routePrefix: "/api/v1",
allowedRoutes: ["/api/v1/*"],
server: {
host: "localhost",
jsonLimit: "20mb",
},
},
{
id: "admin.nehonix.xyz", // β Replace with your domain
port: 9383,
routePrefix: "/admin",
allowedRoutes: ["/admin/*"],
},Replace:
server.nehonix.xyzβapi.yourdomain.comor your preferred API subdomainadmin.nehonix.xyzβadmin.yourdomain.comor your admin subdomain
Important Notes:
- These .xyz domains are for testing purposes only
- Set up DNS A records pointing to your VPS IP address
- Ensure your domains are properly configured before running the XyNginC plugin
Edit src/routes/index.ts:
// Add new routes with type safety
router.get("/api/new-endpoint", (req: Request, res: Response) => {
res.json({ message: "New endpoint" });
});Edit src/middleware/index.ts:
// Add custom middleware with proper typing
app.use((req: Request, res: Response, next: NextFunction) => {
console.log(`${req.method} ${req.path}`);
next();
});Use Fortify Schema for request validation with TypeScript:
import { Interface } from "fortify-schema";
const userSchema = Interface({
username: "username",
email: "email",
password: "password",
});
// Use in routes with type safety
router.post(
"/api/users",
validateBody(userSchema),
(req: Request, res: Response) => {
// Request is validated and typed
const userData = req.body; // Fully typed
res.json({ success: true, user: userData });
}
);FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 9837
CMD ["npm", "start"]npm install -g pm2
pm2 start dist/server.js --name "xynginc-demo" --watch
pm2 startup
pm2 saveThe XyNginC plugin automatically generates optimal Nginx configuration:
- Reverse proxy setup
- SSL certificate integration
- Security headers
- Gzip compression
- Rate limiting
xypriss- Main frameworkxypriss-security- Security utilitiesfortify-schema- Validation librarynehonix-uri-processor- URI processingnquickdev- Development serverxynginc- Nginx and SSL management plugin
typescript- TypeScript compiler@types/node- Node.js type definitionsbun- Fast JavaScript runtimeprisma- Database toolkit
- HTTPS Redirect: Automatic redirect from HTTP to HTTPS
- Security Headers: Comprehensive security headers (HSTS, CSP, etc.)
- Rate Limiting: Built-in request rate limiting
- Input Validation: Schema-based request validation
- JWT Authentication: Secure token-based authentication
- File Upload Security: Secure file upload handling
The application provides comprehensive health monitoring:
GET /health- Basic health statusGET /api/status- Detailed application status- Automatic service restart on failure (with PM2)
Application logs are available through:
- PM2 logs:
pm2 logs xynginc-demo - Nginx logs:
/var/log/nginx/ - System logs:
journalctl -u nginx
- Fork the repository
- Create a feature branch
- Make your changes with proper TypeScript types
- Test thoroughly on a VPS environment
- Submit a pull request
This project is licensed under the MIT License.
- Built with β€οΈ using XyPriss Framework
- Powered by XyNginC Plugin for seamless Nginx integration
- SSL certificates provided by Let's Encrypt
Ready to test XyNginC in production? Clone and deploy this demo on your VPS today!