Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): allow sync handlers #1102

Merged
merged 11 commits into from
Sep 17, 2023

Conversation

cjbt
Copy link
Contributor

@cjbt cjbt commented Sep 12, 2023

closes #1096

  • Extended Handler type from aws-lambda and created a new LambdaHandler type to include an additional return type
  • updated MiddyInputHandler to take in additional non async return type.

packages/core/index.test-d.ts Fixed Show resolved Hide resolved
} from 'aws-lambda'

// extended Handler type from aws-lambda
// to include synced TResult
type LambdaHandler<TEvent = any, TResult = any> = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an ideal solution is to somehow extend the return type of the original Handler type from aws. Looking to see if that's even possible.

} from 'aws-lambda'

type ModifyReturnType<T, NewReturn> = T extends (
Copy link
Contributor Author

@cjbt cjbt Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I landed on an implementation. This gives it the ability to still depend on Handler from aws while it returns the new synced type

@willfarrell willfarrell merged commit 3fd50b8 into middyjs:main Sep 17, 2023
7 checks passed
@willfarrell
Copy link
Member

Thanks for this! I'll get it released shortly

@cjbt cjbt deleted the issue-1096-accept-sync-handlers branch September 17, 2023 20:53
mergify bot referenced this pull request in SvenKirschbaum/share.kirschbaum.cloud Sep 24, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@middy/core](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fcore/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fcore/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fcore/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fcore/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fcore/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/error-logger](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2ferror-logger/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2ferror-logger/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2ferror-logger/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2ferror-logger/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2ferror-logger/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/http-content-negotiation](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fhttp-content-negotiation/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-content-negotiation/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-content-negotiation/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-content-negotiation/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-content-negotiation/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/http-error-handler](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fhttp-error-handler/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-error-handler/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-error-handler/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-error-handler/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-error-handler/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/http-header-normalizer](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fhttp-header-normalizer/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-header-normalizer/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-header-normalizer/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-header-normalizer/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-header-normalizer/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/http-json-body-parser](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fhttp-json-body-parser/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-json-body-parser/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-json-body-parser/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-json-body-parser/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-json-body-parser/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/http-response-serializer](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fhttp-response-serializer/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-response-serializer/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-response-serializer/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-response-serializer/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-response-serializer/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/validator](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fvalidator/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fvalidator/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fvalidator/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fvalidator/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fvalidator/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>middyjs/middy (@&#8203;middy/core)</summary>

### [`v4.6.4`](https://togithub.com/middyjs/middy/releases/tag/4.6.4)

[Compare Source](https://togithub.com/middyjs/middy/compare/4.6.3...4.6.4)

##### What's Changed

-   fix(core): allow sync handlers by [@&#8203;cjbt](https://togithub.com/cjbt) in [https://github.com/middyjs/middy/pull/1102](https://togithub.com/middyjs/middy/pull/1102)

**Full Changelog**: middyjs/middy@4.6.3...4.6.4

### [`v4.6.3`](https://togithub.com/middyjs/middy/releases/tag/4.6.3)

[Compare Source](https://togithub.com/middyjs/middy/compare/4.6.2...4.6.3)

##### What's Changed

-   Fixed s3 headers\[headerName].trim is not a function [#&#8203;1097](https://togithub.com/middyjs/middy/issues/1097) [@&#8203;carrickkv2](https://togithub.com/carrickkv2)

**Full Changelog**: middyjs/middy@4.6.2...4.6.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 5am on sunday" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/SvenKirschbaum/share.kirschbaum.cloud).
mergify bot referenced this pull request in SvenKirschbaum/aws-utils Sep 24, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@middy/core](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fcore/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fcore/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fcore/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fcore/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fcore/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/error-logger](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2ferror-logger/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2ferror-logger/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2ferror-logger/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2ferror-logger/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2ferror-logger/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/http-error-handler](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fhttp-error-handler/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-error-handler/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-error-handler/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-error-handler/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-error-handler/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/http-header-normalizer](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fhttp-header-normalizer/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-header-normalizer/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-header-normalizer/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-header-normalizer/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-header-normalizer/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@middy/http-response-serializer](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.6.2` -> `4.6.4`](https://renovatebot.com/diffs/npm/@middy%2fhttp-response-serializer/4.6.2/4.6.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-response-serializer/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-response-serializer/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-response-serializer/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-response-serializer/4.6.2/4.6.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>middyjs/middy (@&#8203;middy/core)</summary>

### [`v4.6.4`](https://togithub.com/middyjs/middy/releases/tag/4.6.4)

[Compare Source](https://togithub.com/middyjs/middy/compare/4.6.3...4.6.4)

##### What's Changed

-   fix(core): allow sync handlers by [@&#8203;cjbt](https://togithub.com/cjbt) in [https://github.com/middyjs/middy/pull/1102](https://togithub.com/middyjs/middy/pull/1102)

**Full Changelog**: middyjs/middy@4.6.3...4.6.4

### [`v4.6.3`](https://togithub.com/middyjs/middy/releases/tag/4.6.3)

[Compare Source](https://togithub.com/middyjs/middy/compare/4.6.2...4.6.3)

##### What's Changed

-   Fixed s3 headers\[headerName].trim is not a function [#&#8203;1097](https://togithub.com/middyjs/middy/issues/1097) [@&#8203;carrickkv2](https://togithub.com/carrickkv2)

**Full Changelog**: middyjs/middy@4.6.2...4.6.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 5am on sunday" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/SvenKirschbaum/aws-utils).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Middy handler always requires an async handler
3 participants