Skip to content

Ashwin-973/DevSuite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 

Repository files navigation

DevSuite 🚀

Node.js Express Supabase License API

Developer productivity tools as a service - A production-ready REST API suite providing essential utilities for modern development workflows.

📋 Table of Contents

🔍 Overview

DevSuite is a comprehensive collection of developer productivity tools exposed through a clean, RESTful API. Built with Node.js, Express 5, and Supabase, it provides battle-tested utilities that developers need daily, all accessible through simple HTTP requests.

Why DevSuite?

  • 🎯 All-in-One: Six major tool categories in a single API
  • ⚡ High Performance: Optimized with caching, connection pooling, and efficient algorithms
  • 🔒 Production-Ready: Rate limiting, input validation, security headers, and comprehensive error handling
  • 🌍 Global Coverage: Timezone operations with IANA database, GeoNames, and MaxMind integration
  • 📊 Analytics: Built-in URL analytics and request latency monitoring
  • 🛡️ Robust: Graceful error handling with detailed error responses

✨ Features

🔗 URL Shortener

Production-grade URL shortening service with analytics and expiration control.

  • Base62 Encoding: Collision-resistant short IDs using database auto-increment
  • Click Analytics: Track clicks, last accessed time, and creation timestamps
  • Expiration Control: Set custom TTL using human-readable formats (7d, 24h, 30m)
  • Supabase Integration: Leverages PostgreSQL stored procedures for atomic click increments
  • Redirect Service: Fast 302 redirects with automatic click tracking

📝 Text Transformation

Comprehensive text processing utilities for encoding, formatting, and conversion.

  • Base64 Encoding/Decoding: Bidirectional Base64 transformation
  • URL Encoding/Decoding: Percent-encoding for URL-safe strings
  • Slugify: Convert text to URL-friendly slugs with customizable separators (hyphen, underscore)
  • Case Conversion: Support for camelCase, snake_case, kebab-case, PascalCase, CONSTANT_CASE, and more
  • Morse Code: Bidirectional Morse code translation with international support

🌍 Timezone & Time Operations

Enterprise-grade timezone conversion and time retrieval with multiple data sources.

  • Multi-Source Time Lookup: Get current time via IP (MaxMind), coordinates (geo-tz), or location name (GeoNames)
  • Intelligent Timezone Conversion: Handles ISO 8601 with explicit offsets, IANA timezone IDs, and ambiguous inputs
  • Smart Offset Handling: Automatically corrects URL-decoded + signs in timezone offsets
  • Custom Formatting: User-defined time format patterns using Luxon tokens
  • Comprehensive Metadata: Returns timezone abbreviations, DST status, UTC offsets, and warnings
  • Robust Error Handling: Graceful degradation with detailed error messages and audit trails
  • Private IP Detection: Prevents geolocation of private/reserved IP addresses
  • Coordinate Validation: Validates lat/lon ranges and handles international waters

⏰ Cron Expression Tools

Parse, validate, and preview cron expressions with human-readable translations.

  • Expression Translation: Convert cron syntax to natural language using cronstrue
  • Execution Preview: Calculate next N execution times using cron-parser
  • Comprehensive Validation: Validates 5-field and 6-field cron expressions
  • Human-Readable Output: "At 09:00 AM, only on Monday" instead of "0 9 * * 1"

🔍 HTTP Analysis & Monitoring

Deep inspection of HTTP headers, security policies, and endpoint health.

  • Header Analysis: Analyze cache-control, security headers, and CORS policies
  • Security Auditing: Check for HSTS, CSP, X-Frame-Options, and other security headers
  • Cache Policy Inspection: Detailed breakdown of cache directives with human-readable summaries
  • URL Health Checks: Monitor endpoint availability, latency, HTTP status, and SSL certificate validity
  • SSL Certificate Analysis: Extract issuer, expiration date, and validation status
  • IP Resolution: Capture resolved IP addresses for monitored endpoints
  • SSRF Protection: Validates URLs and blocks requests to private IP ranges

🚀 Quick Start

Prerequisites

  • Node.js 18+ (ES Modules support required)
  • Supabase Account (for PostgreSQL database)
  • GeoNames Account (optional, for location-based timezone lookup)
  • MaxMind Account (optional, for IP-based geolocation)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/devsuite.git
    cd devsuite/backend
  2. Install dependencies

    npm install
  3. Configure environment variables

    Create a .env file in the backend directory:

    # Server Configuration
    PORT=3000
    NODE_ENV=development
    
    # Supabase Configuration (Required)
    SUPABASE_URL=https://your-project.supabase.co
    SUPABASE_KEY=your-anon-key
    
    # GeoNames API (Optional - for city/country timezone lookup)
    GEONAMES_USERNAME=your-username
    
    # MaxMind GeoIP2 (Optional - for IP-based geolocation)
    MAXMIND_ACCOUNT_ID=your-account-id
    MAXMIND_LICENSE_KEY=your-license-key
  4. Set up Supabase database

    Run the following SQL in your Supabase SQL editor:

    -- Create URLs table
    CREATE TABLE urls (
      id BIGSERIAL PRIMARY KEY,
      short_id VARCHAR(20) UNIQUE NOT NULL,
      original_url TEXT NOT NULL,
      clicks INTEGER DEFAULT 0,
      created_at TIMESTAMP DEFAULT NOW(),
      last_accessed TIMESTAMP,
      expires_at TIMESTAMP
    );
    
    -- Create stored procedure for atomic click increment
    CREATE OR REPLACE FUNCTION increment_clicks(short_id_param VARCHAR)
    RETURNS VOID AS $$
    BEGIN
      UPDATE urls
      SET clicks = clicks + 1,
          last_accessed = NOW()
      WHERE short_id = short_id_param;
    END;
    $$ LANGUAGE plpgsql;
    
    -- Create index for faster lookups
    CREATE INDEX idx_short_id ON urls(short_id);
    CREATE INDEX idx_expires_at ON urls(expires_at);
  5. Start the server

    npm run dev  # Development mode with nodemon
    npm start    # Production mode

The API will be available at http://localhost:3000

Health check: curl http://localhost:3000/health

📚 API Documentation

Base URL

http://localhost:3000/api/v1

Authentication

No authentication required. Rate limiting: 1000 requests per 15 minutes per IP.

Response Format

All successful responses follow this format:

{
  "success": true,
  "message": "Operation completed successfully",
  "data": {
    // Response payload
  }
}

Error responses:

{
  "success": false,
  "message": "Error description",
  "code": "ERROR_CODE",
  "statusCode": 400
}

🔧 Configuration

Environment Variables

Variable Description Required Default
PORT Server port No 3000
NODE_ENV Environment (development/production) No development
SUPABASE_URL Supabase project URL Yes -
SUPABASE_KEY Supabase anon/public key Yes -
GEONAMES_USERNAME GeoNames API username No demo
MAXMIND_ACCOUNT_ID MaxMind account ID No -
MAXMIND_LICENSE_KEY MaxMind license key No -

Database Configuration

DevSuite uses Supabase (PostgreSQL) for data persistence. The URL shortener requires the urls table and increment_clicks stored procedure (see Quick Start section).

📖 Usage Examples

🔗 URL Shortener

Shorten a URL

curl -X POST http://localhost:3000/api/v1/url/shorten \
  -H "Content-Type: application/json" \
  -d '{
    "originalUrl": "https://github.com/yourusername/devsuite",
    "expiresIn": "7d"
  }'

Response:

{
  "success": true,
  "message": "URL shortened successfully",
  "data": {
    "shortId": "aB3xY",
    "shortUrl": "http://localhost:3000/api/v1/url/aB3xY",
    "originalUrl": "https://github.com/yourusername/devsuite",
    "expiresAt": "2025-01-15T10:30:00.000Z"
  }
}

Redirect to original URL

curl -L http://localhost:3000/api/v1/url/aB3xY
# Automatically redirects and increments click count

Get analytics

curl http://localhost:3000/api/v1/url/analytics/aB3xY

Response:

{
  "success": true,
  "data": {
    "clicks": 42,
    "createdAt": "2025-01-08T10:30:00.000Z",
    "lastAccessed": "2025-01-08T15:45:00.000Z",
    "expiresAt": "2025-01-15T10:30:00.000Z"
  }
}

📝 Text Transformation

Base64 Encode

curl -X POST "http://localhost:3000/api/v1/text/base64?op=encode" \
  -H "Content-Type: application/json" \
  -d '{"input": "Hello DevSuite!"}'

Base64 Decode

curl -X POST "http://localhost:3000/api/v1/text/base64?op=decode" \
  -H "Content-Type: application/json" \
  -d '{"input": "SGVsbG8gRGV2U3VpdGUh"}'

URL Encode

curl -X POST "http://localhost:3000/api/v1/text/url?op=encode" \
  -H "Content-Type: application/json" \
  -d '{"input": "hello world & special chars!"}'

Slugify

curl -X POST "http://localhost:3000/api/v1/text/slugify?separator=hyphen" \
  -H "Content-Type: application/json" \
  -d '{"input": "The Amazing DevSuite 2024!"}'
# Returns: "the-amazing-devsuite-2024"

Case Conversion

# camelCase
curl -X POST "http://localhost:3000/api/v1/text/case?type=camel" \
  -H "Content-Type: application/json" \
  -d '{"input": "convert this to camel case"}'
# Returns: "convertThisToCamelCase"

# snake_case
curl -X POST "http://localhost:3000/api/v1/text/case?type=snake" \
  -H "Content-Type: application/json" \
  -d '{"input": "Convert This To Snake Case"}'
# Returns: "convert_this_to_snake_case"

# PascalCase
curl -X POST "http://localhost:3000/api/v1/text/case?type=pascal" \
  -H "Content-Type: application/json" \
  -d '{"input": "convert this to pascal case"}'
# Returns: "ConvertThisToPascalCase"

Morse Code

# Encode to Morse
curl -X POST "http://localhost:3000/api/v1/text/morse?op=encode" \
  -H "Content-Type: application/json" \
  -d '{"input": "SOS"}'
# Returns: "... --- ..."

# Decode from Morse
curl -X POST "http://localhost:3000/api/v1/text/morse?op=decode" \
  -H "Content-Type: application/json" \
  -d '{"input": "... --- ..."}'
# Returns: "SOS"

🌍 Timezone Operations

Get Current Time by City and Country

curl "http://localhost:3000/api/v1/time/now?city=London&country=United-Kingdom"

Response:

{
  "success": true,
  "data": {
    "location": "London, United Kingdom",
    "timezone": "Europe/London",
    "currentTime": "2025-01-08T15:30:00.000Z",
    "localTime": "2025-01-08T15:30:00.000+00:00",
    "utcOffset": "+00:00",
    "isDST": false,
    "source": "City/Country Lookup (GeoNames)"
  }
}

Get Current Time by IP Address

curl "http://localhost:3000/api/v1/time/now?ip=8.8.8.8"

Get Current Time by Coordinates

curl "http://localhost:3000/api/v1/time/now?lat=40.7128&lon=-74.0060"

Convert Time Between Timezones

# With explicit offset (offset takes precedence over fromZone)
curl "http://localhost:3000/api/v1/time/convert?dateTime=2025-10-20T15:00:00%2B05:30&fromZone=Australia/Perth&toZone=America/Noronha"

# Without offset (uses fromZone)
curl "http://localhost:3000/api/v1/time/convert?dateTime=2025-10-20T15:00:00&fromZone=America/New_York&toZone=Asia/Tokyo"

Response:

{
  "success": true,
  "data": {
    "original": {
      "dateTime": "2025-10-20T15:00:00+05:30",
      "timezone": "UTC+05:30",
      "utcOffset": "+05:30"
    },
    "converted": {
      "dateTime": "2025-10-20T07:30:00-02:00",
      "timezone": "America/Noronha",
      "utcOffset": "-02:00",
      "isDST": false
    },
    "warnings": ["fromZone was provided but ignored because the DateTime string included an explicit offset."]
  }
}

Format Time

curl "http://localhost:3000/api/v1/time/format?dateTime=2025-01-08T15:30:00&zone=America/New_York&format=yyyy-MM-dd%20HH:mm:ss%20ZZZZ"

Lookup Timezone Metadata

curl "http://localhost:3000/api/v1/time/lookup?city=Tokyo&country=Japan"

⏰ Cron Expression Tools

Translate Cron to Human-Readable

curl "http://localhost:3000/api/v1/cron/translate?expression=0%209%20*%20*%201"

Response:

{
  "success": true,
  "data": {
    "expression": "0 9 * * 1",
    "description": "At 09:00 AM, only on Monday"
  }
}

Preview Next Executions

curl "http://localhost:3000/api/v1/cron/preview?expression=0%209%20*%20*%201&count=5"

Response:

{
  "success": true,
  "data": {
    "expression": "0 9 * * 1",
    "description": "At 09:00 AM, only on Monday",
    "nextRuns": [
      "2025-01-13T09:00:00.000Z",
      "2025-01-20T09:00:00.000Z",
      "2025-01-27T09:00:00.000Z",
      "2025-02-03T09:00:00.000Z",
      "2025-02-10T09:00:00.000Z"
    ]
  }
}

🔍 HTTP Analysis & Monitoring

Analyze HTTP Headers

curl "http://localhost:3000/api/v1/analyze/headers?url=https://github.com"

Response:

{
  "success": true,
  "data": {
    "url": "https://github.com",
    "checkedAt": "2025-01-08T15:30:00.000Z",
    "httpStatus": 200,
    "rawHeaders": {
      "cache-control": "max-age=0, private, must-revalidate",
      "strict-transport-security": "max-age=31536000; includeSubdomains; preload",
      "x-frame-options": "deny"
    },
    "analysis": {
      "cache": {
        "summary": "This resource can be cached by browsers only (not shared caches) for 0 seconds.",
        "directives": {
          "max-age": 0,
          "private": true,
          "no-cache": true
        }
      },
      "security": {
        "summary": "Enforces HTTPS (HSTS). Blocks clickjacking (X-Frame-Options: DENY). Prevents MIME-sniffing.",
        "directives": {
          "strict-transport-security": "max-age=31536000; includeSubdomains; preload",
          "x-frame-options": "deny"
        }
      },
      "cors": {
        "summary": "No CORS headers found.",
        "directives": {}
      }
    }
  }
}

Monitor URL Health

curl "http://localhost:3000/api/v1/analyze/url?url=https://api.github.com&timeout=5000"

Response:

{
  "success": true,
  "data": {
    "url": "https://api.github.com",
    "status": "UP",
    "httpStatus": 200,
    "ipAddress": "140.82.121.6",
    "latencyMs": 145,
    "ssl": {
      "isValid": true,
      "issuer": "DigiCert Inc",
      "expiresOn": "2026-03-15T12:00:00.000Z",
      "error": null
    },
    "error": null
  }
}

Check API Health

curl http://localhost:3000/health

Response:

{
  "status": "OK",
  "timestamp": "Wed Jan 08 2025 15:30:00 GMT+0000 (UTC)"
}

🐳 Docker Deployment

Build and run with Docker:

# Build image
docker build -t devsuite .

# Run with docker-compose
docker-compose up -d

The docker-compose.yml includes PostgreSQL setup and environment configuration.

🏗️ Architecture

DevSuite follows a clean, layered architecture:

├── src/
│   ├── controllers/     # HTTP request handlers
│   ├── services/        # Business logic layer  
│   ├── models/          # Data access layer
│   ├── routes/          # API route definitions
│   ├── middleware/      # Express middleware
│   ├── utils/           # Utility functions
│   └── config/          # Configuration files
├── scripts/             # Setup and deployment scripts
├── docs/                # API documentation
└── tests/               # Test suites

🔒 Security

  • Rate Limiting: 1000 requests per 15 minutes per IP
  • Input Validation: Comprehensive input sanitization and validation
  • SQL Injection Protection: Parameterized queries
  • Security Headers: Helmet.js for security headers
  • CORS: Configurable cross-origin resource sharing

📊 Performance

  • Connection Pooling: PostgreSQL connection pooling for optimal performance
  • Caching: In-memory caching for frequently accessed data
  • Optimized Queries: Indexed database queries for fast lookups
  • Lightweight: Minimal overhead with efficient algorithms

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Commit your changes: git commit -am 'Add amazing feature'
  5. Push to the branch: git push origin feature/amazing-feature
  6. Submit a pull request

Code Style

  • Follow existing code style and conventions
  • Add JSDoc comments for new functions
  • Include tests for new features
  • Update documentation as needed

📝 Changelog

See CHANGELOG.md for detailed release notes.

🛠️ Roadmap

  • Authentication & Authorization: JWT-based authentication system
  • API Rate Limiting: Per-user rate limiting with different tiers
  • Webhook Support: Real-time notifications for URL clicks and health checks
  • Data Export: Export analytics data in various formats (CSV, JSON, PDF)
  • Custom Domains: Support for custom short domains
  • Bulk Operations: Batch processing for multiple URLs and text transformations
  • GraphQL API: Alternative GraphQL interface
  • Real-time Dashboard: Web-based analytics dashboard
  • Monitoring Alerts: Email/SMS alerts for health check failures
  • Advanced Cron: Support for more complex scheduling patterns

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Express.js - Fast, unopinionated web framework
  • PostgreSQL - Powerful, open-source relational database
  • Joi - Object schema validation
  • Helmet - Security middleware for Express

📞 Support


WebsiteDocumentationAPI ReferenceDiscord

Made with ❤️ by developers, for developers.

Releases

No releases published

Packages

 
 
 

Contributors