Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/lwsPublic

A lean, modular web server for rapid full-stack development.

License

NotificationsYou must be signed in to change notification settings

lwsjs/lws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

view on npmnpm module downloadsGihub repo dependentsGihub package dependentsNode.js CI

lws

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.

Synopsis

Core usage

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:8000

For 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:8000

Now your server is running, the next step is to attach some middleware to process requests.

Using middleware plugins

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:8000

The 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 ms

Creating a custom middleware plugin

Lws 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!

Install

$ npm install --save-dev lws

Documentation

See also


© 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

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp