-
-
Notifications
You must be signed in to change notification settings - Fork 796
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: event.resource in catch-all route gets + changed to * (#1524)
- Loading branch information
Showing
6 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict' | ||
|
||
const { stringify } = JSON | ||
|
||
exports.hello = async (event) => { | ||
return { | ||
body: stringify({ | ||
path: event.path, | ||
resource: event.resource, | ||
}), | ||
statusCode: 200, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "commonjs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
service: uncategorized-tests | ||
|
||
configValidationMode: error | ||
|
||
plugins: | ||
- ../../../../ | ||
|
||
provider: | ||
memorySize: 128 | ||
name: aws | ||
region: us-east-1 # default | ||
runtime: nodejs16.x | ||
stage: dev | ||
versionFunctions: false | ||
|
||
functions: | ||
hello: | ||
events: | ||
- http: | ||
method: any | ||
path: /{proxy+} | ||
handler: handler.hello |
27 changes: 27 additions & 0 deletions
27
tests/endToEnd/starRoutesRestApi/starRoutesRestApi.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import assert from 'node:assert' | ||
import { dirname, resolve } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import { BASE_URL } from '../../config.js' | ||
import { setup, teardown } from '../../_testHelpers/index.js' | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)) | ||
|
||
describe('star routes', function desc() { | ||
beforeEach(() => | ||
setup({ | ||
servicePath: resolve(__dirname, 'src'), | ||
}), | ||
) | ||
|
||
afterEach(() => teardown()) | ||
|
||
describe('when a catch all route is used in a rest api', () => { | ||
it('it should return a payload', async () => { | ||
const url = new URL('/dev/hello', BASE_URL) | ||
const response = await fetch(url) | ||
const json = await response.json() | ||
|
||
assert.deepEqual(json, { path: '/hello', resource: '/{proxy+}' }) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters