{"id":13402984,"url":"https://github.com/lwsjs/local-web-server","last_synced_at":"2025-05-14T14:07:32.300Z","repository":{"id":38418840,"uuid":"10477388","full_name":"lwsjs/local-web-server","owner":"lwsjs","description":"A lean, modular web server for rapid full-stack development.","archived":false,"fork":false,"pushed_at":"2024-08-01T08:46:04.000Z","size":5788,"stargazers_count":1244,"open_issues_count":6,"forks_count":89,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-05-12T14:22:11.135Z","etag":null,"topics":["backend","full-stack","lws","progressive-web-app","server","single-page-app","web-development","web-server","webapp","webapplication"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lwsjs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-06-04T11:46:06.000Z","updated_at":"2025-05-11T14:18:21.000Z","dependencies_parsed_at":"2024-01-13T22:48:26.549Z","dependency_job_id":"b2e62eb4-169e-4402-93f6-693d49b45a57","html_url":"https://github.com/lwsjs/local-web-server","commit_stats":{"total_commits":568,"total_committers":5,"mean_commits":113.6,"dds":0.008802816901408494,"last_synced_commit":"9f45cc467085e1d2967b03afbb65be297cee9cb4"},"previous_names":[],"tags_count":147,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwsjs%2Flocal-web-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwsjs%2Flocal-web-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwsjs%2Flocal-web-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwsjs%2Flocal-web-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lwsjs","download_url":"https://codeload.github.com/lwsjs/local-web-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254159194,"owners_count":22024558,"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":["backend","full-stack","lws","progressive-web-app","server","single-page-app","web-development","web-server","webapp","webapplication"],"created_at":"2024-07-30T19:01:23.778Z","updated_at":"2025-05-14T14:07:32.282Z","avatar_url":"https://github.com/lwsjs.png","language":"JavaScript","readme":"[![view on npm](https://badgen.net/npm/v/local-web-server)](https://www.npmjs.org/package/local-web-server)\n[![npm module downloads](https://badgen.net/npm/dt/local-web-server)](https://www.npmjs.org/package/local-web-server)\n[![Gihub repo dependents](https://badgen.net/github/dependents-repo/lwsjs/local-web-server)](https://github.com/lwsjs/local-web-server/network/dependents?dependent_type=REPOSITORY)\n[![Gihub package dependents](https://badgen.net/github/dependents-pkg/lwsjs/local-web-server)](https://github.com/lwsjs/local-web-server/network/dependents?dependent_type=PACKAGE)\n[![Node.js CI](https://github.com/lwsjs/local-web-server/actions/workflows/node.js.yml/badge.svg)](https://github.com/lwsjs/local-web-server/actions/workflows/node.js.yml)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)\n\n*Upgraders, please read the [release notes](https://github.com/lwsjs/local-web-server/releases). For feedback, discussion and support see [here](https://github.com/lwsjs/local-web-server/discussions).*\n\n# local-web-server\n\nA lean, modular web server for rapid full-stack development.\n\n* Supports HTTP, HTTPS and HTTP2.\n* Small and 100% personalisable. Load and use only the behaviour required by your project.\n* Attach a custom view to personalise how activity is visualised.\n* Programmatic and command-line interfaces.\n\nUse this tool to:\n\n* Build any type of front-end web application (static, dynamic, Single Page App, Progessive Web App, React etc).\n* Prototype a back-end service (REST API, microservice, websocket, Server Sent Events service etc).\n* Monitor activity, analyse performance, experiment with caching strategy etc.\n\nLocal-web-server is a distribution of [lws](https://github.com/lwsjs/lws) bundled with a \"starter pack\" of useful middleware.\n\n## Synopsis\n\nThis package installs the `ws` command-line tool (take a look at the [usage guide](https://github.com/lwsjs/local-web-server/wiki/CLI-usage)).\n\n### Static web site\n\nRunning `ws` without any arguments will host the current directory as a static web site. Navigating to the server will render a directory listing or your `index.html`, if that file exists.\n\n```sh\n$ ws\nListening on http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:8000\n```\n\n[Static files tutorial](https://github.com/lwsjs/local-web-server/wiki/How-to-serve-static-files).\n\nThis clip demonstrates static hosting plus a couple of log output formats - `dev` and `stats`.\n\n\u003cimg src=\"https://raw.githubusercontent.com/lwsjs/local-web-server/master/examples/log-format.gif\" width=\"618px\" title=\"Static static log output\"\u003e\n\n\n### Single Page Application\n\nServing a Single Page Application (an app with client-side routing, e.g. a React or Angular app) is as trivial as specifying the name of your single page:\n\n```sh\n$ ws --spa index.html\n```\n\nWith a static site, requests for typical SPA paths (e.g. `/user/1`, `/login`) would return `404 Not Found` as a file at that location does not exist. However, by marking `index.html` as the SPA you create this rule:\n\n*If a static file is requested (e.g. `/css/style.css`) then serve it, if not (e.g. `/login`) then serve the specified SPA and handle the route client-side.*\n\n[SPA tutorial](https://github.com/lwsjs/local-web-server/wiki/How-to-serve-a-Single-Page-Application-(SPA)).\n\n\u003cimg src=\"https://raw.githubusercontent.com/lwsjs/local-web-server/master/examples/spa.gif\" width=\"618px\" title=\"SPA\"\u003e\n\n### URL rewriting and proxied requests\n\nAnother common use case is to forward certain requests to a remote server.\n\nThe following command proxies blog post requests from any path beginning with `/posts/` to `https://jsonplaceholder.typicode.com/posts/`. For example, a request for `/posts/1` would be proxied to `https://jsonplaceholder.typicode.com/posts/1`.\n\n```sh\n$ ws --rewrite '/posts/(.*) -\u003e https://jsonplaceholder.typicode.com/posts/$1'\n```\n\n[Rewrite tutorial](https://github.com/lwsjs/local-web-server/wiki/How-to-rewrite-URLs-to-local-or-remote-destinations).\n\nThis clip demonstrates the above plus use of `--static.extensions` to specify a default file extension and `--verbose` to monitor activity.\n\n\u003cimg src=\"https://raw.githubusercontent.com/lwsjs/local-web-server/master/examples/verbose.gif\" width=\"618px\" title=\"Proxy json requests to remote resource\"\u003e\n\n### HTTPS and HTTP2\n\nFor HTTPS or HTTP2, pass the `--https` or `--http2` flags respectively. [See the wiki](https://github.com/lwsjs/local-web-server/wiki) for further configuration options and a guide on how to get the \"green padlock\" in your browser.\n\n```\n$ ws --http2\nListening at https://mba4.local:8000, https://127.0.0.1:8000, https://192.168.0.200:8000\n```\n\n## Built-in middleware stack\n\nIf you do *not* supply a custom middleware stack via the `--stack` option the following default stack will be used. It's designed to cover most typical web development scenarios.\n\n| Name               | Description |\n| ------------------ | ---- |\n| ↓ [Basic Auth](https://github.com/lwsjs/basic-auth) | Password-protect a server using Basic Authentication |\n| ↓ [Body Parser](https://github.com/lwsjs/body-parser) | Parses the request body, making `ctx.request.body` available to downstream middleware.|\n| ↓ [Request Monitor](https://github.com/lwsjs/request-monitor) | Feeds traffic information to the `--verbose` output.|\n| ↓ [Log](https://github.com/lwsjs/log) | Outputs an access log or stats view to the console.|\n| ↓ [Cors](https://github.com/lwsjs/cors) | Support for setting Cross-Origin Resource Sharing (CORS) headers |\n| ↓ [Json](https://github.com/lwsjs/json) | Pretty-prints JSON responses. |\n| ↓ [Rewrite](https://github.com/lwsjs/rewrite) | URL Rewriting. Use to re-route requests to local or remote destinations.|\n| ↓ [Blacklist](https://github.com/lwsjs/blacklist) | Forbid access to sensitive or private resources|\n| ↓ [Conditional Get](https://github.com/lwsjs/conditional-get) | Support for HTTP Conditional requests.|\n| ↓ [Mime](https://github.com/lwsjs/mime) | Customise the mime-type returned with any static resource.|\n| ↓ [Compress](https://github.com/lwsjs/compress) | Compress responses using gzip.|\n| ↓ [SPA](https://github.com/lwsjs/spa) | Support for Single Page Applications.|\n| ↓ [Static](https://github.com/lwsjs/static) | Serves static files.|\n| ↓ [Index](https://github.com/lwsjs/index) | Serves directory listings.|\n\n## Further Documentation\n\n[See the wiki for plenty more documentation and tutorials](https://github.com/lwsjs/local-web-server/wiki).\n\n## Install\n\n```sh\n$ npm install -g local-web-server\n```\n\n* * *\n\n\u0026copy; 2013-24 Lloyd Brookes \\\u003c75pound@gmail.com\\\u003e. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwsjs%2Flocal-web-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flwsjs%2Flocal-web-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwsjs%2Flocal-web-server/lists"}