Giter Club home page Giter Club logo

deno-filewatcher's Introduction

deno-filewatcher

A Deno websocket server and client that can watch a filesystem. The server watches the specified directory and notifies the connected clients about any changes to the files in the watched directory tree. The clients can also request the file contents of the directory being watched.

Prerequisites

  • The Deno runtime:
    curl -fsSL https://deno.land/x/install/install.sh | sh

Running

  1. First start the server:

    deno --allow-net --allow-read filewatcher-server.ts -d directory/to/watch -p 3000

    This will start the filewatcher server on port 3000. If you don't specify a port, the server will default to port 8080. (use the --help to view all the command line options)

  2. Next start the client(s):

    deno --allow-net filewatcher-client.ts http://localhost:3000

    The server URL is optional. If you don't provide the server URL, then the client will default to http://localhost:8080 (which is the default server port)

The server won't actually start watching the filesystem until there is at least one client connected. And the server will stop watching the filesystem if all the clients disconnect. When a client first connects the server will inform the client about all the files that are in the watched directory. From that point forward the client will receive notifications only for modifed and removed files.

While the client is running, from the client CLI, you can type:

file::my_files/foo.txt

to view the contents of the file my_files/foo.txt (this is the path relative to the directory being watched).

Additionally, you can type:

close

to quit the client session.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.