Skip to content

tomberek/ssentr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ssentr

Send SSE when files change.

Setup:

$ cat Caddyfile
{
	http_port 8085
}
:8085 {
	route /reload {
		header Access-Control-Allow-Origin *
		header Access-Control-Request-Method GET
		reloader
	}
}

Usage:

find -iname '*.html' | ssentr run

Add the following hyperscript to your project

<script type="text/hyperscript">
eventsource Reloader from http://localhost:8085/reload
    on message
        call location.reload()
    end
    on error
        log "error with connecting to reload SSE"
    end
    on close
        log "closing reload SSE"
    end
end
</script>

When any of the files change, a message will be sent to any connection to http://localhost:8085/reloader

Building

With nix

nix build
ls | ./result/bin/ssentr run

With xcaddy

xcaddy build --with github.com/tomberek/ssentr/reloader
ls | ./caddy run

Credit

Based on and is an extension of Caddy Inspired by entr(1) Used along with hyperscript

About

Send SSE when files change

Resources

License

Stars

Watchers

Forks

Packages

No packages published