Skip to content

Feature: Publish as NPM package with CLI tools #17

@shigahi

Description

@shigahi

Summary

Publish Worknot as an NPM package with CLI tools for easier setup, configuration, and deployment.

Current Behavior

Users must:

  1. Visit the web UI
  2. Fill in the form
  3. Copy the generated script
  4. Manually create a Cloudflare Worker
  5. Paste the script

This process is manual and error-prone.

Proposed Solution

NPM Package Structure

worknot/
├── src/
│   ├── index.ts          # Main export
│   ├── proxy.ts          # Core proxy logic
│   ├── types.ts          # TypeScript definitions
│   ├── cli/
│   │   ├── init.ts       # npx worknot init
│   │   └── generate.ts   # npx worknot generate
│   ├── handlers/         # Request handlers
│   └── rewriters/        # HTML rewriters
├── templates/
│   ├── config.js         # Config template
│   ├── head.css          # Custom CSS template
│   ├── body.js           # Custom JS template
│   └── header.html       # Custom header template
└── package.json

CLI Commands

# Initialize a new Worknot project
npx worknot init

# Generate optimized files from config
npx worknot generate

# Deploy to Cloudflare Workers
npx worknot deploy

Usage as Library

import { initializeWorknot } from 'worknot';
import { SITE_CONFIG } from './worknot/config';

const proxy = initializeWorknot(SITE_CONFIG);

export default {
  async fetch(request: Request): Promise<Response> {
    return proxy(request);
  },
};

Benefits

  • Faster setup (5 minutes vs 15+ minutes)
  • Version control for configuration
  • TypeScript support with full type safety
  • Easier updates via npm
  • CI/CD integration
  • Local development support

Reference

Nooxy provides full NPM package with CLI: https://www.npmjs.com/package/nooxy

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions