joakimunge / denoliver Goto Github PK
View Code? Open in Web Editor NEWA simple, dependency free static file server for Deno with possibly the worst name ever.
License: MIT License
A simple, dependency free static file server for Deno with possibly the worst name ever.
License: MIT License
Hi!
To clarify, your "live reload" feature isn't live reload of the browser is it, it's live reload of the server?:
Hope this helps & to hear back
Cheers
PS looks like a thoughtfully considered project - props for learning Deno this way ๐
I run denoliver ./src
but I got this error
error: Uncaught NotFound: No such file or directory (os error 2) at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11) at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10) at async Object.open ($deno$/files.ts:37:15) at async Object.readFile ($deno$/read_file.ts:13:16) at async readFile (https://deno.land/x/denoliver/utils.ts:36:25) at async handleRouteRequest (https://deno.land/x/denoliver/mod.ts:55:16)
Tried installing today (first time) and it failed.
If I had to guess I would say that it would be better fixing the version of the https://deno.land/std/http/server.ts
instead of using the implicit latest version, since you can bump into API changes that can break denoliver
.
โ deno --version
deno 1.14.3 (release, x86_64-apple-darwin)
v8 9.4.146.16
typescript 4.4.2
โ deno install --allow-net --allow-read --allow-write --allow-run https://deno.land/x/denoliver/mod.ts
Check https://deno.land/x/denoliver/mod.ts
error: TS2305 [ERROR]: Module '"https://deno.land/[email protected]/http/server.ts"' has no exported member 'ServerRequest'.
import { ServerRequest } from 'https://deno.land/std/http/server.ts'
~~~~~~~~~~~~~
at https://deno.land/x/[email protected]/utils/utils.ts:2:10
TS2305 [ERROR]: Module '"https://deno.land/[email protected]/http/server.ts"' has no exported member 'serveTLS'.
serveTLS,
~~~~~~~~
at https://deno.land/x/[email protected]/mod.ts:7:3
TS2305 [ERROR]: Module '"https://deno.land/[email protected]/http/server.ts"' has no exported member 'ServerRequest'.
ServerRequest,
~~~~~~~~~~~~~
at https://deno.land/x/[email protected]/mod.ts:8:3
TS2741 [ERROR]: Property 'next' is missing in type 'FsWatcher' but required in type 'AsyncIterableIterator<FsEvent>'.
watcher = Deno.watchFs(root, { recursive: true })
~~~~~~~
at https://deno.land/x/[email protected]/mod.ts:135:5
'next' is declared here.
next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at asset:///lib.es2018.asynciterable.d.ts:34:5
TS2504 [ERROR]: Type 'Server' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
for await (const req of server) {
~~~~~~
at https://deno.land/x/[email protected]/mod.ts:227:29
TS2554 [ERROR]: Expected 2-3 arguments, but got 1.
: serve({ port })
~~~~~~~~~~~~~~~
at https://deno.land/x/[email protected]/mod.ts:324:7
An argument for 'handler' was not provided.
handler: Handler,
~~~~~~~~~~~~~~~~
at https://deno.land/[email protected]/http/server.ts:561:3
Found 6 errors.
Hey, great work with Denoliver ! Is there any future plan to allow a full programmatic usage of the lib ?
Atm, the function exported from mod.ts
is usable but does not enable the use of the options usable from cli (--port
, --silent
...).
Example of usage could be something like:
import serve from "https://deno.land/x/denoliver/mod.ts";
serve({ p: 3000, s: true, n: false, root: './dist' })
Currently denoliver is only tested and supported on OSX.
Would be nice to have it run on Linux as well. I don't imagine it requiring too much work
Currently denoliver is only tested and supported on OSX.
Would be nice to have it run on Windows 10 as well. I don't imagine it requiring too much work
I am getting the error
Check https://deno.land/x/denoliver/mod.ts
error: TS2339 [ERROR]: Property 'getIterator' does not exist on type 'ReadableStream<R>'.
return res.readable.getIterator();
~~~~~~~~~~~
at https://deno.land/[email protected]/async/pool.ts:45:23
upon install with deno 1.16.1
Would be nice to set up a github action that runs tests in more environments. (Linux/osx/win)
Deno has with 1.18.0
implemented native support for network intefaces. This now makes deno-local-ip
obsolete.
More here and how to use it: denoland/deno#13475
I would like to flesh out the directory listing feature by showing file information like (type, weight)
Although I don't want to clutter the interface, so maybe only weight is enough (file type should be visible in name).
Maybe extended info on hover?
Something I have wanted to implement for a while is a sort of injectable middleware feature.
An idea is maybe to have a cli flag --middleware
which accepts a path to a ts/js
-file that would contain a list of middleware functions that would be executed in order before each request. So that users can inject their own logging, or whatever else they would like to enhance their experience
e.g: denoliver ./src --middleware=/path/to/middleware.js
and in the config file:
{
...
"middleware:" "/path/to/middleware.ts
...
}
Could also be something like beforeRequest
and afterRequest
or something similar
Deno has with version 1.18 released a native http api which I intend to support. This will probably result in a lot of breaking changes.
More here: https://deno.land/[email protected]/runtime/http_server_apis
Denoliver crashes after a few hours with active use.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 24, kind: Other, message: "Too many open files" }', cli/fs.rs:87:15
stack backtrace:
0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
1: core::fmt::write
2: std::io::Write::write_fmt
3: std::panicking::default_hook::{{closure}}
4: std::panicking::default_hook
5: std::panicking::rust_panic_with_hook
6: rust_begin_unwind
7: core::panicking::panic_fmt
8: core::option::expect_none_failed
9: deno::fs::resolve_from_cwd
10: deno::permissions::Permissions::resolved_and_display_path
11: deno::permissions::Permissions::check_read
12: deno::ops::fs::op_open
13: deno::state::State::core_op::{{closure}}
14: deno_core::core_isolate::CoreIsolateState::dispatch_op
15: deno_core::bindings::send
16: <extern "C" fn(A0) .> R as rusty_v8::support::CFnFrom<F>>::mapping::c_fn
17: _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
18: _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
19: _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
/Users/xxxxxxxx/.deno/bin/denoliver: line 3: 13193 Abort trap: 6 deno "run" "--allow-read" "--allow-net" "https://deno.land/x/denoliver/mod.ts" "$@"
It would be nice to have an entry point for a SPA. Like if the html file is not there then look for a 404.html
file and redirect to there. Ideally be able to have different 404.html
files. Like if I request /app/something/here
and /app/something/here/index.html
doesn't exist then look for /app/something/here/404.html
then /app/something/404.html
then /app/404.html
and finally 404.html
. And then default to your 404 file if none of those exists.
I would like the ability to opt into serving files with gzip and/or brotli.
Maybe a new --compression
flag where you can specify the type?
Need to write contribution guidelines. Should include:
Please check this error:
BadResource: Bad resource ID
at unwrapResponse (
at Object.sendAsync (
at async handleWs (https://deno.land/x/denoliver/mod.ts:84:22)
at async router (https://deno.land/x/denoliver/mod.ts:104:12)
index.html
<script type="module" src="js/app.js"></script>js/app.js
import { Button } from 'https://cdn.pika.dev/antd@^4.3.1';
import React from 'https://cdn.pika.dev/react@^16.13.1'
import ReactDOM from 'https://cdn.pika.dev/react-dom@^16.13.1';
const e = React.createElement;
class LikeButton extends React.Component {
constructor(props) {
super(props);
this.state = { liked: false };
}
render() {
if (this.state.liked) {
return 'You liked this.';
}
return e(
'button',
{ onClick: () => this.setState({ liked: true }) },
'Like'
);
}
}
const root = document.querySelector('#root');
ReactDOM.render(e(LikeButton), root);
Hi!
Can you help me with this error?
sanyatuning@penguin:~/repos/Bundler/examples/lit_element$ denoliver src -d --before=before.ts -h
TypeError: An unsupported media type was attempted to be imported as a module.
Specifier: https://deno.land/home/sanyatuning/repos/Bundler/examples/lit_element/src/before.ts
MediaType: Unknown
at async setGlobals (https://deno.land/x/[email protected]/mod.ts:256:30)
at async https://deno.land/x/[email protected]/mod.ts:357:3
deno version (latest)
sanyatuning@penguin:~/repos/Bundler/examples/lit_element$ deno --version
deno 1.10.2 (release, x86_64-unknown-linux-gnu)
v8 9.1.269.27
typescript 4.2.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.