Skip to content

Feature: jsserve - npx serve alternative with write support (new repo) #108

@melvincarvalho

Description

@melvincarvalho

Summary

Create jsserve - a thin wrapper package around JSS that provides a drop-in alternative to npx serve with added REST write capabilities (PUT/DELETE).

New repo: github.com/JavaScriptSolidServer/jsserve

Difficulty: 20/100
Estimated Effort: 1 day
Dependencies: #107 (--public flag)


Motivation

npx serve is hugely popular for quick static file serving, but it's read-only. Developers often need:

  • Quick file upload endpoint for testing
  • Simple WebDAV-like functionality
  • REST API for local development
  • File sync between devices on LAN

jsserve fills this gap: "serve, but you can write too"


Comparison

Feature npx serve npx jsserve
Zero config
Static file serving
Directory listings
CORS
Custom port
SPA mode
PUT (write files)
DELETE
PATCH
ETags/caching
Conditional requests
Upgrade to Solid

Usage

# Install
npm i -g jsserve

# Serve current directory (read + write enabled)
jsserve

# Serve specific folder
jsserve ./public

# Custom port
jsserve -p 8080

# Read-only mode (exactly like npx serve)
jsserve --read-only

# With basic auth
jsserve --auth user:pass

# Enable full Solid features
jsserve --solid

Output

   ┌─────────────────────────────────────────┐
   │                                         │
   │   Serving!                              │
   │                                         │
   │   - Local:    http://localhost:3000     │
   │   - Network:  http://192.168.1.5:3000   │
   │                                         │
   │   GET/PUT/DELETE enabled                │
   │                                         │
   └─────────────────────────────────────────┘

REST API Examples

# Read file
curl http://localhost:3000/file.txt

# Write file
curl -X PUT -d "content" http://localhost:3000/file.txt

# Delete file
curl -X DELETE http://localhost:3000/file.txt

# Conditional update (optimistic concurrency)
curl -X PUT -H 'If-Match: "etag"' -d "new" http://localhost:3000/file.txt

Repository Structure

github.com/JavaScriptSolidServer/jsserve/
├── bin/
│   └── jsserve.js          # CLI entry point (~80 LOC)
├── package.json            # Depends on jss
├── README.md
└── LICENSE

Implementation

The wrapper is ~80 LOC that:

  1. Parses serve-compatible CLI args
  2. Translates to JSS flags
  3. Spawns JSS with --public flag
  4. Prints a nice banner
{
  "name": "jsserve",
  "bin": { "jsserve": "./bin/jsserve.js" },
  "dependencies": {
    "commander": "^12.0.0",
    "jss": "^0.1.0"
  }
}

Difficulty Breakdown

Component LOC Difficulty
CLI wrapper ~80 10/100
Package setup ~20 5/100
README/docs ~100 5/100
Total ~200 20/100

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions