Browse Source

add lws-request-monitor

master
Lloyd Brookes 7 years ago
parent
commit
b1bc8bed96
  1. 7
      README.md
  2. 1
      lib/command/middleware-list.js
  3. 1
      lib/command/serve.js
  4. 1
      lib/local-web-server.js
  5. 7
      package.json

7
README.md

@ -41,7 +41,7 @@ Serving at http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:80
Another common use case is to **proxy certain requests to a remote server** if, for example, you'd like to use data from a different environment. The following command would proxy requests with a URL beginning with `http://127.0.0.1:8000/api/` to `https://internal-service.local/api/`:
```sh
$ ws --rewrite '/api/* -> https://internal-service.local/api/$1`
$ ws --rewrite '/api/* -> https://internal-service.local/api/$1'
Serving at http://mbp.local:8000, http://127.0.0.1:8000, http://192.168.0.100:8000
```
@ -73,8 +73,9 @@ module.exports = [
response: function (ctx) {
const newUser = ctx.request.body
users.push(newUser)
newUser.id = users.length
ctx.status = 201
ctx.response.set('Location', `/users/${users.length}`)
ctx.response.set('Location', `/users/${newUser.id}`)
}
}
]
@ -82,7 +83,7 @@ module.exports = [
]
```
Next, launch `ws` passing in your mock response file:
Next, launch `ws` passing in your mock response file:
```sh
$ ws --mocks example-mocks.js

1
lib/command/middleware-list.js

@ -4,6 +4,7 @@ class MiddlewareList {
}
execute (options) {
const list = [
'lws-request-monitor',
'lws-log',
'lws-cors',
'lws-json',

1
lib/command/serve.js

@ -14,6 +14,7 @@ class WsServe extends ServeCommand {
.set('cd4', 'cli')
options = {
stack: [
'lws-request-monitor',
'lws-log',
'lws-cors',
'lws-json',

1
lib/local-web-server.js

@ -12,6 +12,7 @@ class LocalWebServer extends Lws {
moduleDir: path.resolve(__dirname, `../node_modules`),
modulePrefix: 'lws-',
stack: [
'lws-request-monitor',
'lws-log',
'lws-cors',
'lws-json',

7
package.json

@ -32,19 +32,20 @@
"repository": "https://github.com/lwsjs/local-web-server",
"author": "Lloyd Brookes <75pound@gmail.com>",
"dependencies": {
"lws": "^1.0.0-pre2.6",
"lws": "^1.0.0-pre2.7",
"lws-blacklist": "^0.2.1",
"lws-body-parser": "^0.2.2",
"lws-compress": "^0.2.1",
"lws-conditional-get": "^0.3.3",
"lws-cors": "^0.3.2",
"lws-index": "^0.3.1",
"lws-index": "^0.3.2",
"lws-json": "^0.3.2",
"lws-log": "^0.3.0",
"lws-mime": "^0.2.1",
"lws-mock-response": "^0.2.3",
"lws-request-monitor": "^0.1.0",
"lws-rewrite": "^0.3.4",
"lws-spa": "^0.2.1",
"lws-spa": "^0.2.2",
"lws-static": "^0.3.4"
},
"devDependencies": {

Loading…
Cancel
Save