Skip to content

Commit ff0cec7

Browse files
committed
fix: improved alb request query string parsing
updated docs
1 parent 856492b commit ff0cec7

File tree

6 files changed

+53
-72
lines changed

6 files changed

+53
-72
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-aws-lambda",
3-
"version": "4.6.5",
3+
"version": "4.6.6",
44
"description": "AWS Application Load Balancer and API Gateway - Lambda dev tool for Serverless. Allows Express synthax in handlers. Supports packaging, local invoking and offline ALB, APG, S3, SNS, SQS, DynamoDB Stream server mocking.",
55
"author": "Inqnuam",
66
"license": "MIT",

resources/defineConfig.md

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ export default defineConfig({
3535
});
3636
```
3737

38-
### Create a custom plugin which may be used inside defineConfig's `plugins`
38+
#### Create a custom plugin which may be used inside defineConfig's `plugins`
3939

4040
```js
41-
/**
42-
* @type {import("serverless-aws-lambda/defineConfig").SlsAwsLambdaPlugin}
43-
*/
44-
const myCustomPlugin = {
41+
import { defineConfig } from "serverless-aws-lambda/defineConfig";
42+
import type { SlsAwsLambdaPlugin } from "serverless-aws-lambda/defineConfig";
43+
44+
const myCustomPlugin:SlsAwsLambdaPlugin = {
4545
name: "my-custom-plugin",
4646
onInit: async function () {
4747
// do something
@@ -81,7 +81,7 @@ export default defineConfig({
8181
8282
8383
84-
module.exports = defineConfig({
84+
export default defineConfig({
8585
esbuild: {
8686
target: "es2020",
8787
},
@@ -92,18 +92,3 @@ module.exports = defineConfig({
9292
plugins: [myCustomPlugin],
9393
});
9494
```
95-
96-
`defineConfig` can be imported as ESM as well.
97-
98-
```js
99-
import { defineConfig } from "serverless-aws-lambda/defineConfig";
100-
import { sqsPlugin } from "serverless-aws-lambda/sqs";
101-
102-
export default defineConfig({
103-
offline: {
104-
staticPath: "./.aws_lambda",
105-
port: 9999,
106-
},
107-
plugins: [sqsPlugin()],
108-
});
109-
```

resources/offline.md

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,30 @@ Set offline static path, custom port and add request listeners:
22

33
```js
44
// config.js
5-
module.exports = ({ lambdas, isDeploying, isPackaging, setEnv, stage, port }) => {
6-
/**
7-
* @type {import("serverless-aws-lambda").Config}
8-
*/
9-
return {
10-
esbuild: {
11-
//...
5+
import { defineConfig } from "serverless-aws-lambda/defineConfig";
6+
7+
export default defineConfig({
8+
esbuild: {
9+
//...
10+
},
11+
offline: {
12+
staticPath: "./public",
13+
port: 9999,
14+
onReady: (port) => {
15+
console.log("We are ready to listen on", port);
1216
},
13-
offline: {
14-
staticPath: "./public",
15-
port: 9999,
16-
onReady: (port) => {
17-
console.log("We are ready to listen on", port);
18-
},
19-
request: [
20-
{
21-
filter: /^\/__routes(\/)?$/, // filters request when request URL match /__routes
22-
callback: (req, res) => {
23-
// node http request Incoming Message and Response object
24-
res.statusCode = 404;
25-
res.end(`${req.url} not found`);
26-
},
17+
request: [
18+
{
19+
filter: /^\/__routes(\/)?$/, // filters request when request URL match /__routes
20+
callback: (req, res) => {
21+
// node http request Incoming Message and Response object
22+
res.statusCode = 404;
23+
res.end(`${req.url} not found`);
2724
},
28-
],
29-
},
30-
};
31-
};
25+
},
26+
],
27+
},
28+
});
3229
```
3330

3431
### virtualEnvs
@@ -70,24 +67,23 @@ functions:
7067
```
7168
7269
```js
73-
// config.js
74-
module.exports = ({ lambdas, isDeploying, isPackaging, setEnv, stage, port }) => {
75-
return {
76-
esbuild: {
77-
// ...
78-
},
79-
offline: {
80-
// ...
81-
},
82-
buildCallback: async (result) => {
83-
const foundLambda = lambdas.find((x) => x.name == "players");
70+
import { defineConfig } from "serverless-aws-lambda/defineConfig";
8471

85-
if (foundLambda) {
86-
console.log(foundLambda.virtualEnvs);
87-
}
88-
},
89-
};
90-
};
72+
export default defineConfig({
73+
esbuild: {
74+
// ...
75+
},
76+
offline: {
77+
// ...
78+
},
79+
buildCallback: async (result) => {
80+
const foundLambda = lambdas.find((x) => x.name == "players");
81+
82+
if (foundLambda) {
83+
console.log(foundLambda.virtualEnvs);
84+
}
85+
},
86+
});
9187
```
9288

9389
## Run serverless-aws-lambda programmatically

resources/sns.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Import the plugin inside your defineConfig.
99

1010
```js
1111
// config.js
12-
const { defineConfig } = require("serverless-aws-lambda/defineConfig");
13-
const { snsPlugin } = require("serverless-aws-lambda/sns");
12+
import { defineConfig } from "serverless-aws-lambda/defineConfig";
13+
import { snsPlugin } = from "serverless-aws-lambda/sns";
1414

15-
module.exports = defineConfig({
15+
export default defineConfig({
1616
plugins: [snsPlugin()],
1717
});
1818
```

resources/sqs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Import the plugin inside your defineConfig.
1313

1414
```js
1515
// config.js
16-
const { defineConfig } = require("serverless-aws-lambda/defineConfig");
17-
const { sqsPlugin } = require("serverless-aws-lambda/sqs");
16+
import { defineConfig } from "serverless-aws-lambda/defineConfig";
17+
import { sqsPlugin } = from "serverless-aws-lambda/sqs";
1818

19-
module.exports = defineConfig({
19+
export default defineConfig({
2020
plugins: [sqsPlugin(config)],
2121
});
2222
```

src/plugins/lambda/events/alb.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ export class AlbRequestHandler extends CommonEventGenerator {
235235
const queryComponents = queryString.split("&");
236236

237237
queryComponents.forEach((c) => {
238-
const [key, value] = c.split("=");
239-
queryStringComponents[key] = value;
238+
const [key, ...value] = c.split("=");
239+
queryStringComponents[key] = value.join("=");
240240
});
241241

242242
delete queryStringComponents.x_mock_type;

0 commit comments

Comments
 (0)