{"id":13736728,"url":"https://github.com/joakimunge/denoliver","last_synced_at":"2025-04-12T06:06:16.513Z","repository":{"id":38015566,"uuid":"264416102","full_name":"joakimunge/denoliver","owner":"joakimunge","description":"A simple, dependency free static file server for Deno with possibly the worst name ever.","archived":false,"fork":false,"pushed_at":"2022-06-12T01:20:11.000Z","size":720,"stargazers_count":99,"open_issues_count":8,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T06:06:06.642Z","etag":null,"topics":["cli","deno","denoland","dependency-free","dev-server","file-server","live-reload","server","typescript","web-server"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joakimunge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-16T10:51:42.000Z","updated_at":"2025-04-05T07:35:10.000Z","dependencies_parsed_at":"2022-09-14T01:02:07.583Z","dependency_job_id":null,"html_url":"https://github.com/joakimunge/denoliver","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimunge%2Fdenoliver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimunge%2Fdenoliver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimunge%2Fdenoliver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimunge%2Fdenoliver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joakimunge","download_url":"https://codeload.github.com/joakimunge/denoliver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525144,"owners_count":21118618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","deno","denoland","dependency-free","dev-server","file-server","live-reload","server","typescript","web-server"],"created_at":"2024-08-03T03:01:27.420Z","updated_at":"2025-04-12T06:06:16.489Z","avatar_url":"https://github.com/joakimunge.png","language":"TypeScript","funding_links":[],"categories":["Tools","基础设施"],"sub_categories":["Online Playgrounds","Assistants","JAM Stack/静态站点","XML"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"media/denoliver_2.png\" title=\"Denoliver\" alt=\"It's a liver\" width=\"320\" style=\"margin: 48px 48px\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\" style=\"margin-top: 48px\"\u003e\n\u003ca href=\"https://github.com/joakimunge/denoliver/actions\"\u003e\n\u003cimg src=\"https://img.shields.io/github/workflow/status/joakimunge/denoliver/ci?style=for-the-badge\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/joakimunge/denoliver/releases\"\u003e\n\u003cimg src=\"https://img.shields.io/github/v/release/joakimunge/denoliver?style=for-the-badge\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n**Denoliver** is a small, zero config dev \u0026 static file server with live reloading written in TypeScript for Deno intended for prototyping and Single Page Applications.\n\n## Prerequisites\n\n### To run this you need to have [Deno](https://deno.land/) 1.0 or later installed.\n\n## Key Features\n\n- Dependency free! No third party dependencies.\n- Live reload\n- Supports client side routing for Single Page Applications.\n- Directory lists\n- Supports HTTPS\n- Allows for programmatic use as a module\n- Boilerplating for rapid prototyping.\n- Injectable HTTP request interceptors. (TS \u0026 JS)\n\n## Getting started\n\nInstall as a Deno executable.\n\n\u003e NOTE: Deno is a secure runtime by default. You need to include the `--allow-net`, `--allow-read` and `--allow-write` flags to make sure Denoliver can serve your directory.\n\n```\n$ deno install --allow-net --allow-read --allow-write --allow-run https://deno.land/x/denoliver/mod.ts\n```\n\nor if you're not happy with the name:\n\n```\n$ deno install -n whateverNameYouWant --allow-net --allow-read --allow-write --allow-run https://deno.land/x/denoliver/mod.ts\n```\n\n## Why do I need the `--allow-run` flag?\n\n_You don't need it! You can still use Denoliver as normal without this flag._\n\nCurrently Deno does not provide a way to access local network interfaces, so to do this you need to allow denoliver to spawn the subprocess `ipconfig` and fetch the address from there. When [this](https://github.com/denoland/deno/issues/3802) implementation gets finished, this module will probably be deprecated.\n\nThis code is published for you to use here: https://github.com/joakimunge/deno-local-ip/\n\n## Running\n\nServe your directory\n\n```s\n$ denoliver ./demo\n```\n\n## Options\n\nDenoliver comes with a couple of options to customize your experience.\n\n```s\n-h                 # Help\n-n                 # Disable live reload - Defaults to false\n-s                 # Disable all output - Defaults to false\n-p \u003cPORT\u003e          # Specify desired port - Defaults to 8080\n-d                 # Debug for more verbose output - Defaults to false\n-t                 # Use HTTPS - Requires a trusted self-signed certificate\n-l                 # Use directory listings - Disables routing (SPA)\n-c                 # Use CORS - Defaults to false\n--before=\u003c..\u003e   # Before request Interceptor(s)\n--after=\u003c..\u003e    # After request Interceptor(s)\n--certFile=\u003c..\u003e    # Specify certificate file - Defaults to denoliver.crt\n--keyFile=\u003c..\u003e     # Specify key file - Defaults to denoliver.key\n--entry=\u003c..\u003e       # Specify optional entrypoint - Defaults to index.html\n```\n\n### Directory Listing\n\nDenoliver supports indexing of served directories and provides a simple interface, with dark mode support, for navigating a project folder.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"media/list.png\" alt=\"Directory listing\"\u003e\n\u003c/p\u003e\n\n### Optional boilerplating\n\nIf the given directory doesn't exist, denoliver will ask you if you want to create a boilerplate. This will generate an a basic project folder and serve it for you. Very useful to get up and running quickly.\n\n```\n├── index.html\n├── index.css\n├── app.js\n```\n\n### Interceptors\n\nDenoliver allows you to inject your own request interceptors to be fired before or after the HTTP requests has been handled by the server.\nThis can be one or more functions which have access to the request object (instance of [Deno.Request](https://doc.deno.land/builtin/stable#Request)) and gets called in the order they are defined with the output of the previous function (piped). **These functions must all return the request object.**\n\nInterceptors can be a single function, for example:\n\n```typescript\n// before.ts\n\nexport default (req: ServerRequest) =\u003e {\n  req.headers.set('Authorization', 'Bearer some-token')\n  return req\n}\n```\n\nor an array of functions:\n\n```typescript\nconst setHeaders = (req: ServerRequest) =\u003e {\n  req.headers.set('Authorization', 'Bearer some-token')\n  return req\n}\n\nconst logRequestUrl = (req: ServerRequest) =\u003e {\n  console.log(req.url)\n  return req\n}\n\nexport default [setHeaders, logRequestUrl]\n```\n\nof course this can also be used when using Denoliver as a module:\n\n```typescript\nconst server = denoliver({\n  port: 6060,\n  before: (req: ServerRequest) =\u003e {\n    req.headers.set('Authorization', 'Bearer some-token')\n    return req\n  },\n})\n```\n\n## Configuration\n\nIf you want, you can place a configuration file called `denoliver.json` in the folder you are serving to avoid having to use command line arguments to customize its behaviour. By default it will look like this:\n\n```JSON\n{\n  \"root\": \".\",\n  \"port\": 8080,\n  \"disableReload\": false,\n  \"silent\": false,\n  \"debug\": false,\n  \"secure\": false,\n  \"cors\": false,\n  \"list\": false,\n  \"before\": \"before.ts\",\n  \"after\": \"after.ts\",\n  \"certFile\": \"some_file.crt\",\n  \"keyFile\": \"some_file.key\",\n  \"entryPoint\": \"index.html\"\n}\n```\n\n## API\n\nDenoliver can also be used as a module in any Deno project.\nThis exposes an instance of [Deno.Server](https://deno.land/std/http/server.ts#L125).\n\nThe main function accepts the same config object as specified in the config file above.\n\n```typescript\nimport denoliver from 'https://deno.land/x/denoliver/mod.ts'\n\nconst server = denoliver({ port: 6060, cors: true })\n\nserver.close() // Close the server\n```\n\n## Serve over HTTPS\n\nTo use HTTPS you will need a trusted self-signed certificate. If you're on macOS you can use [This](https://github.com/kingkool68/generate-ssl-certs-for-local-development) bash script to easily generate one.\n\nName the cert and key files `denoliver.crt` and `denoliver.key` and place them in your working dir. You can configure these names to be whatever you want with the config file, or the `--certFile` and `--keyFile` flags.\n\n## Disclaimer\n\n**This project is not intended for production use. It started out as a way for me personally to learn Deno, and is merely a tool to quickly get a file server up and running.**\n\n## Acknowledgements\n\nThis project was heavily inspired by [lukejacksonn](https://github.com/lukejacksonn)s fantastic [Servor](https://github.com/lukejacksonn/servor/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakimunge%2Fdenoliver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoakimunge%2Fdenoliver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakimunge%2Fdenoliver/lists"}