npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serve-rw

v1.0.7

Published

A simple http file server that also allows PUT and DELETE operations

Downloads

4

Readme

serve-rw

Serve-RW is a lightweight file server that supports reading, writing, and deleting files via HTTP requests. It allows you to easily expose a directory over HTTP with MIME types, directory listings, and full CORS support. You can use PUT requests to upload or replace files and DELETE requests to remove them.

🚀 Features

  • Dynamic File Serving: Serve files with correct MIME types.
  • Directory Listing: Auto-generates an HTML listing for directories.
  • File Uploads: Upload or replace files via PUT requests.
  • File Deletion: Remove files using DELETE requests.
  • CORS Enabled: Open to any origin, making it accessible for external resources.
  • Command-Line Configurable: Easily configure the port and root directory.
  • Error Handling: Errors are shown in HTML and logged to the console.

📦 Installation

You can install serve-rw globally using npm:

npm install -g serve-rw

Alternatively, you can clone the repository:

git clone https://github.com/n3rdyme/serve-rw.git
cd serve-rw
npm install

🛠️ Usage

Once installed, you can run the server with:

serve-rw --port <port> --directory <path>

Command-Line Options:

  • --port <port>: Specify the port the server listens on (default: 3000).
  • --directory <path>: Set the root directory for serving files (default: ./config).

Example:

serve-rw --port 8080 --directory /path/to/your/directory

🌐 API Endpoints

1. GET - Retrieve Files and Directories

Access any file or directory via a GET request. If the path is a directory, an HTML page listing its contents will be returned.

Example:

curl http://localhost:8080/myfile.txt

2. PUT - Upload or Replace Files

Use a PUT request to upload a new file or replace an existing one.

Example:

curl -X PUT --data-binary @yourfile.txt http://localhost:8080/uploadedfile.txt

3. DELETE - Remove Files

Use a DELETE request to remove a specific file.

Example:

curl -X DELETE http://localhost:8080/myfile.txt

📂 Directory Listing

When a directory is requested, an HTML page with a listing of its contents will be returned. The page includes navigation links to subdirectories and a link to the parent directory (if applicable).

⚠️ Error Handling

If an error occurs (e.g., a file is not found or the server encounters an issue), a user-friendly HTML error page will be returned, and the error will be logged to the console for easy debugging.

🛠 Development

If you'd like to contribute:

  1. Fork the repository.
  2. Create your feature branch:
    git checkout -b feature/my-new-feature
  3. Commit your changes:
    git commit -am 'Add new feature'
  4. Push the branch:
    git push origin feature/my-new-feature
  5. Submit a pull request.

📝 License

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


Find this project on GitHub: n3rdyme/serve-rw


Now you can easily expose directories over HTTP with full read-write capabilities using serve-rw. Happy serving!