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

feat: object-syntax event handlers #485

Merged
merged 13 commits into from
Aug 7, 2023
Merged

feat: object-syntax event handlers #485

merged 13 commits into from
Aug 7, 2023

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Aug 3, 2023

πŸ”— Linked issue

#417
resolves #424

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This supports object-syntax event handlers with the following syntax:

defineEventHandler({
  handler: () => {},
  before: [],
  after: []
})

Helper validate functions need to be drafted that type-hint event and infer a return type. (I would suggest we also suggest validate: { body: () => {}, query: () => {} } which I think will be easier to directly get a type from as user can just return the validated body/query, which we can then flow through into rest of handlers.)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe self-assigned this Aug 3, 2023
@danielroe danielroe added the enhancement New feature or request label Aug 3, 2023
@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Merging #485 (36da183) into main (7fc1d8b) will decrease coverage by 0.45%.
Report is 2 commits behind head on main.
The diff coverage is 58.18%.

❗ Current head 36da183 differs from pull request most recent head 7e192af. Consider uploading reports for the commit 7e192af to get more accurate results

@@            Coverage Diff             @@
##             main     #485      +/-   ##
==========================================
- Coverage   82.79%   82.34%   -0.45%     
==========================================
  Files          31       31              
  Lines        3424     3473      +49     
  Branches      514      516       +2     
==========================================
+ Hits         2835     2860      +25     
- Misses        589      613      +24     
Files Changed Coverage Ξ”
src/event/utils.ts 62.67% <45.23%> (-9.71%) ⬇️
src/types.ts 100.00% <100.00%> (ΓΈ)
src/utils/cookie.ts 93.78% <100.00%> (ΓΈ)

src/event/utils.ts Outdated Show resolved Hide resolved
src/event/utils.ts Show resolved Hide resolved
src/event/utils.ts Outdated Show resolved Hide resolved
src/event/utils.ts Outdated Show resolved Hide resolved
src/event/utils.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] implement event handler object syntax
2 participants