{"id":20471001,"url":"https://github.com/lwsjs/lws","last_synced_at":"2025-04-09T23:17:33.479Z","repository":{"id":48654936,"uuid":"82599219","full_name":"lwsjs/lws","owner":"lwsjs","description":"A lean, modular web server for rapid full-stack development.","archived":false,"fork":false,"pushed_at":"2024-08-29T17:03:40.000Z","size":955,"stargazers_count":48,"open_issues_count":0,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T23:17:28.692Z","etag":null,"topics":["backend","development-tools","http-server","lws","server","webapp"],"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}},"created_at":"2017-02-20T20:24:53.000Z","updated_at":"2025-03-29T16:12:35.000Z","dependencies_parsed_at":"2022-08-26T09:21:39.848Z","dependency_job_id":null,"html_url":"https://github.com/lwsjs/lws","commit_stats":null,"previous_names":[],"tags_count":79,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwsjs%2Flws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwsjs%2Flws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwsjs%2Flws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwsjs%2Flws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lwsjs","download_url":"https://codeload.github.com/lwsjs/lws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125593,"owners_count":21051771,"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","development-tools","http-server","lws","server","webapp"],"created_at":"2024-11-15T14:14:40.594Z","updated_at":"2025-04-09T23:17:33.460Z","avatar_url":"https://github.com/lwsjs.png","language":"JavaScript","readme":"[![view on npm](https://badgen.net/npm/v/lws)](https://www.npmjs.org/package/lws)\n[![npm module downloads](https://badgen.net/npm/dt/lws)](https://www.npmjs.org/package/lws)\n[![Gihub repo dependents](https://badgen.net/github/dependents-repo/lwsjs/lws)](https://github.com/lwsjs/lws/network/dependents?dependent_type=REPOSITORY)\n[![Gihub package dependents](https://badgen.net/github/dependents-pkg/lwsjs/lws)](https://github.com/lwsjs/lws/network/dependents?dependent_type=PACKAGE)\n[![Node.js CI](https://github.com/lwsjs/lws/actions/workflows/node.js.yml/badge.svg)](https://github.com/lwsjs/lws/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# lws\n\nA lean, modular web server for rapid full-stack development.\n\nLws is an application core for quickly launching a local web server. Behaviour is added via plugins giving you full control over how requests are processed and responses created.\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 APIs.\n\n## Synopsis\n\n### Core usage\n\nLaunch an HTTP server on the default port of 8000.\n\n```\n$ lws\nListening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000\n```\n\nFor HTTPS or HTTP2, pass the `--https` or `--http2` flags respectively.\n\n```\n$ lws --http2\nListening at https://mba4.local:8000, https://127.0.0.1:8000, https://192.168.0.200:8000\n```\n\nNow your server is running, the next step is to attach some middleware to process requests.\n\n### Using middleware plugins\n\nInstall and use some middleware ([lws-static](https://github.com/lwsjs/static) and [lws-index](https://github.com/lwsjs/index)) to serve static files and directory listings.\n\n```\n$ npm install --save-dev lws-static lws-index\n\n$ lws --stack lws-static lws-index\nListening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000\n```\n\nThe current directory will now be available to explore at `http://127.0.0.1:8000`.\n\nInstall and use logging middleware. Note the `lws-` prefix is optional when supplying module names to `--stack`.\n\n```\n$ npm install --save-dev lws-log\n\n$ lws --stack log static index --log.format combined\nListening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000\n::ffff:127.0.0.1 - GET /lws.config.js HTTP/1.1 200 52 - 8.259 ms\n::ffff:127.0.0.1 - GET /package.json HTTP/1.1 200 399 - 1.478 ms\n```\n\n### Creating a custom middleware plugin\n\nLws uses [Koa](https://github.com/koajs/koa/) as its middleware engine. Here is a trivial plugin example, save the following code as `example-middleware.js`:\n\n```js\nclass ExamplePlugin {\n  middleware () {\n    return async (ctx, next) =\u003e {\n      ctx.body = 'Hello from lws!'\n      await next()\n    }\n  }\n}\n\nexport default ExamplePlugin\n```\n\nNow launch an HTTP server using this middleware.\n\n```\n$ lws --stack example-middleware.js\nListening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000\n\n$ curl http://127.0.0.1:8000\nHello from lws!\n```\n\n## Install\n\n```\n$ npm install --save-dev lws\n```\n\n## Documentation\n\n* API Reference\n  * [Lws](https://github.com/lwsjs/lws/blob/master/doc/lws.md)\n  * [Middleware plugin](https://github.com/lwsjs/lws/blob/master/doc/middleware-plugin.md)\n  * [View plugin](https://github.com/lwsjs/lws/blob/master/doc/view-plugin.md)\n\n## See also\n\n* [lws plugin list](https://npms.io/search?q=keywords%3Alws-middleware).\n* [local-web-server](https://github.com/lwsjs/local-web-server), an lws distribution with the most common plugins already installed.\n\n* * *\n\n\u0026copy; 2016-24 Lloyd Brookes \\\u003c75pound@gmail.com\\\u003e.\n\nTested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwsjs%2Flws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flwsjs%2Flws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwsjs%2Flws/lists"}