Skip to content

Commit

Permalink
Modify eslint and prettier to include the examples directory
Browse files Browse the repository at this point in the history
  • Loading branch information
nrayburn-tech committed Jul 24, 2024
1 parent e3f94f3 commit 2bce185
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
36 changes: 21 additions & 15 deletions examples/middleware/bodyDecoder-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const targetPort = getPort();
//
const app = connect()
.use(bodyParser.json()) //json parser
.use(bodyParser.urlencoded({extended: true})) //urlencoded parser
.use(bodyParser.urlencoded({ extended: true })) //urlencoded parser
.use(function (req, res) {
// modify body here,
// eg: req.body = {a: 1}.
Expand Down Expand Up @@ -93,13 +93,16 @@ http.createServer(app1).listen(targetPort, function () {
fetch('http://127.0.0.1:' + proxyPort, {
method: 'POST',
body: JSON.stringify({ content: 123, type: 'greeting from json request' }),
}).then((response) => {
return response.text();
}).then((data => {
console.log('return for json request:', data);
})).catch((err => {
console.error(err);
}));
})
.then((response) => {
return response.text();
})
.then((data) => {
console.log('return for json request:', data);
})
.catch((err) => {
console.error(err);
});

// application/x-www-form-urlencoded request
fetch('http://127.0.0.1:' + proxyPort, {
Expand All @@ -108,11 +111,14 @@ http.createServer(app1).listen(targetPort, function () {
content: 123,
type: 'greeting from urlencoded request',
}),
}).then((response) => {
return response.text();
}).then((data) => {
console.log('return for urlencoded request:', data);
}).catch((err => {
console.error(err);
}));
})
.then((response) => {
return response.text();
})
.then((data) => {
console.log('return for urlencoded request:', data);
})
.catch((err) => {
console.error(err);
});
});
2 changes: 1 addition & 1 deletion examples/middleware/gzip-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ app.use(
// that you need, just for show the example
// we use threshold to 1
threshold: 1,
})
}),
);
app.use(function (req, res) {
proxy.web(req, res);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"scripts": {
"build": "tsup lib/index.ts --target node16 --format cjs,esm --dts --clean",
"examples": "node examples/runner.js",
"format": "prettier --write ./lib",
"lint": "eslint --fix ./lib",
"format": "prettier --write ./lib ./examples",
"lint": "eslint --fix ./lib ./examples",
"test": "vitest run --coverage",
"prepublishOnly": "npm run build"
},
Expand Down

0 comments on commit 2bce185

Please sign in to comment.