Comments (4)
Thanks! I've quickly fixed it myself, as the setup with Rush currently is a bit finicky.
from lambda-middleware.
Ok, I am not quite able to make the mapped type work here, not really sure how to apply it to the type parameter on JSONObject, what I have so far is
type RequiredKeys<T> = { [k in keyof T]-?: undefined extends T[k] ? never : k }[keyof T];
type PickRequiredKeys<T> = Pick<T, RequiredKeys<T>>
but I'm not sure how to use it in the PromiseHandler signature
EDIT: ok, I am able to get unit tests to pass with
type RequiredKeys<T> = { [k in keyof T]-?: undefined extends T[k] ? never : k }[keyof T];
type PickRequiredKeys<T> = Pick<T, RequiredKeys<T>>
export const jsonSerializer = () => (
handler: PromiseHandler<APIGatewayEvent, PickRequiredKeys<JSONObject> | undefined>
However, using a mapped type on the type bound in that signature is bending my brain a little bit so I'm not 100% sure it's correct
from lambda-middleware.
BTW thanks for being so responsive on these libraries, it seems like you're the only maintainer so I really appreciate it as it as they really fit my usecase and I'm frankly surprised they are not more widely used. This isn't strictly as "bug" as much as a limitation, but there was no better template to use. I'm happy to PR with these changes if they make sense to you, I'm still relatively new to typescript (mostly Scala background for this kind of thing) so I am not entirely sure of myself and appreciate the guidance.
from lambda-middleware.
It's released in version 2.1.0
https://www.npmjs.com/package/@lambda-middleware/json-serializer
from lambda-middleware.
Related Issues (20)
- Enable Github Actions to automatically build
- Add typeorm middleware for connecting to a database HOT 3
- Question - Composing multiple middleware HOT 10
- jsonSerializer does not pass through correct event type HOT 4
- Interest in a path parser middleware? HOT 3
- Allowing PromiseHandler to have generic Context HOT 1
- Help with composeHandler response HOT 1
- Middleware ordering causes type conflicts on remaining middleware HOT 1
- @lambda-middleware/utils package is pulling in the entire aws-sdk package HOT 1
- Add a JSON Deserializer Middleware HOT 5
- Add io-ts validator middleware HOT 5
- Should doNotWait middleware make context.callbackWaitsForEmptyEventLoop true instead of boolean? HOT 1
- class-validator seems to break the type inference for the handler HOT 1
- JsonDeserializer does not accept content-type header with charset HOT 2
- JSONSchema validator with AJV HOT 2
- Can we use different event type? Now strict to `APIGatewayEvent ` HOT 2
- Allow deserializeBody to work with APIGatewayProxyEventV2 HOT 1
- Can you please show how to add cors() to a compose chain? HOT 4
- Compatibility with Http API HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lambda-middleware.