Coder Social home page Coder Social logo

joakimunge / denoliver Goto Github PK

View Code? Open in Web Editor NEW
98.0 98.0 10.0 720 KB

A simple, dependency free static file server for Deno with possibly the worst name ever.

License: MIT License

Makefile 0.33% TypeScript 99.67%
cli deno denoland dependency-free dev-server file-server live-reload server typescript web-server

denoliver's People

Contributors

grantcarthew avatar joakimunge avatar michael-spengler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

denoliver's Issues

QUESTION Clarify live reload

Hi!

To clarify, your "live reload" feature isn't live reload of the browser is it, it's live reload of the server?:

  • If yes then I invite you to make this clearer in the README
  • If no then is there a setting, which I've missed, to get live (browser) reload working or do you know of a live (browser) reload tool for Deno yet

Hope this helps & to hear back

Cheers

PS looks like a thoughtfully considered project - props for learning Deno this way ๐Ÿ˜Š

Uncaught NotFound: No such file or directory

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)

Installation failling

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.

Allow denoliver to be used programmatically

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' })

Support for Linux (untested)

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

Support for Windows (untested)

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

Install broken with deno 1.16.1

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

Show file info in directory listings

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?

Injectable interceptors

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

Too many open files

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" "$@"

Entry Point for SPAs

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.

Support compression

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?

Bad Resource ID

Please check this error:
BadResource: Bad resource ID
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
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);

Uncaught Error: Broken Pipe

Broken Pipe error randomly appears. Seems to be an issue with the response not being awaited in some cases.

image

before script import issue

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

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.