-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
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 --solidOutput
┌─────────────────────────────────────────┐
│ │
│ 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.txtRepository 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:
- Parses serve-compatible CLI args
- Translates to JSS flags
- Spawns JSS with
--publicflag - 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
- Feature: --public flag to skip WAC and allow open access #107 -
--publicflag (required dependency) - Feature: Docker Support - Dockerfile, Compose, and Container Registry #99 - Docker (jsserve could have its own image)
- Feature: remoteStorage Protocol Support #106 - remoteStorage (jsserve could enable RS mode)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels