Comments (6)
@Isaac-Leonard , for me this method looks redundant, since you're connecting this db
dependency in the same place where your handler
is implemented, so you can use it directly within handler
without passing it through the factory.
In case this entity somehow depends on incoming data or available for limited users, the existing method .addMiddleware()
is designed for passing the desired entity to the options
parameter of the handler
.
Perhaps I'm missing something. Please let me know if these two solutions are not suitable for your case (with some more details). Thank you!
from express-zod-api.
Actually yeah you're right, I really should read the full documentation first before trying to add features.bThe only differences I would maybe make is to add the properties on options directly to the argument passed to handler instead of as a options property but really that doesn't make much of a difference and not requiring the createMiddleware boilerplate..
from express-zod-api.
Actually no
Looking at it more there is currently no typing on the options object.
Thats what My solution would add.
I've pushed my changes on my fork if you would like to look although they are a bit messy, its got tests demonstrating its typesafeness.
Currently it requires a breaking change as typescript can't infer types without it.
It currently allows for anything to be added to a dependancies object that gets passed to the final handler but only static data for now, making it dynamic such as creating individual db connections or authenticating users with a type safe user object being added to the result however should be doable.
The current options object is just typed as any.
from express-zod-api.
The current options object is just typed as any.
I'd recommend to check the type of your middleware's output and how you connect this middleware.
Usually it works this way (in a project, that utilizes express-zod-api
):
from express-zod-api.
and not requiring the createMiddleware boilerplate..
I agree, that in some cases, especially for empty inputs, there may be some sort of shorthand for providing Endpoints with options easier. Need to think on it a little bit...
from express-zod-api.
@Isaac-Leonard , please check out PR #234.
Does it fulfill your needs?
from express-zod-api.
Related Issues (20)
- `node-fetch` is no longer needed HOT 1
- allow to add annotations for routes for generated client HOT 1
- responseProps HOT 3
- ez.upload() does not work for attached express aplications. HOT 1
- `ez.upload()` does not work with `.attachRouting()` HOT 4
- Type error: `BearerSecurity` cannot be named HOT 4
- Make `winston` a peer
- Problem to create routings HOT 5
- Can't use .z.ZodArray as output schema HOT 6
- Task: Restore SWC for `ts-node` when new version released
- Specifying input headers HOT 8
- TypeScript errors TS4023, TS4094 HOT 11
- Multiple servers in Swagger HOT 2
- Export request/response types from generated client HOT 5
- Listening to a configurable hostname HOT 1
- Insufficient types export (TS4023) of `Metadata` HOT 1
- Task: fix NPM warning during publishing
- Cannot create multiple errors response when generate Document
- Set schema name using withMeta
- Type regression from 16.1.0 to 16.2.0 HOT 3
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 express-zod-api.