- Notifications
You must be signed in to change notification settings - Fork19
A lean, modular web server for rapid full-stack development.
License
lwsjs/lws
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A lean, modular web server for rapid full-stack development.
Lws 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.
- Supports HTTP, HTTPS and HTTP2.
- Small and 100% personalisable. Load and use only the behaviour required by your project.
- Attach a custom view to personalise how activity is visualised.
- Programmatic and command-line APIs.
Launch an HTTP server on the default port of 8000.
$ lwsListening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000For HTTPS or HTTP2, pass the--https or--http2 flags respectively.
$ lws --http2Listening at https://mba4.local:8000, https://127.0.0.1:8000, https://192.168.0.200:8000Now your server is running, the next step is to attach some middleware to process requests.
Install and use some middleware (lws-static andlws-index) to serve static files and directory listings.
$ npm install --save-dev lws-static lws-index$ lws --stack lws-static lws-indexListening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000The current directory will now be available to explore athttp://127.0.0.1:8000.
Install and use logging middleware. Note thelws- prefix is optional when supplying module names to--stack.
$ npm install --save-dev lws-log$ lws --stack log static index --log.format combinedListening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000::ffff:127.0.0.1 - GET /lws.config.js HTTP/1.1 200 52 - 8.259 ms::ffff:127.0.0.1 - GET /package.json HTTP/1.1 200 399 - 1.478 msLws usesKoa as its middleware engine. Here is a trivial plugin example, save the following code asexample-middleware.js:
classExamplePlugin{middleware(){returnasync(ctx,next)=>{ctx.body='Hello from lws!'awaitnext()}}}exportdefaultExamplePlugin
Now launch an HTTP server using this middleware.
$ lws --stack example-middleware.jsListening at http://mba4.local:8000, http://127.0.0.1:8000, http://192.168.0.200:8000$ curl http://127.0.0.1:8000Hello from lws!$ npm install --save-dev lws- API Reference
- lws plugin list.
- local-web-server, an lws distribution with the most common plugins already installed.
© 2016-25 Lloyd Brookes <opensource@75lb.com>.
Documented byjsdoc-to-markdown.
About
A lean, modular web server for rapid full-stack development.
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.