-
How do developers using express-zod-api handle expiration or age in their APIs? Some of my endpoints have data that should expire quickly, and some is more static. I don't see an examples of that in documentation or the usual places. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I presume you're talking about this header: You can set headers either from a Middleware or from ResultHandler, @lpw The handlers of those entities have const shortTermFactory = defaultEndpointsFactory
.addMiddleware(
createMiddleware({
input: z.object({}),
middleware: async ({ response }) => {
response.set("age", 30);
return {};
}
})
); The endpoints produced on |
Beta Was this translation helpful? Give feedback.
-
Sorry for the delay in response - this worked great - thanks again! |
Beta Was this translation helpful? Give feedback.
I presume you're talking about this header:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Age
You can set headers either from a Middleware or from ResultHandler, @lpw
The handlers of those entities have
response
argument, so you can doresponse.set()
:https://expressjs.com/en/api.html#res.set
The endpoints produced on
shortTermFactory
are going to have the header set.