Browse Source

add lws-request-monitor

master
Lloyd Brookes 8 years ago
parent
commit
b1bc8bed96
  1. 5
      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

5
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/`: 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 ```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 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) { response: function (ctx) {
const newUser = ctx.request.body const newUser = ctx.request.body
users.push(newUser) users.push(newUser)
newUser.id = users.length
ctx.status = 201 ctx.status = 201
ctx.response.set('Location', `/users/${users.length}`)
ctx.response.set('Location', `/users/${newUser.id}`)
} }
} }
] ]

1
lib/command/middleware-list.js

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

1
lib/command/serve.js

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

1
lib/local-web-server.js

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

7
package.json

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

Loading…
Cancel
Save