-
I get type error while declaring
// imports
import { Feature, FeatureService } from '@entities/feature.entity';
import {
createServer,
Routing,
z,
defaultEndpointsFactory,
createResultHandler,
createApiResponse,
IOSchema,
EndpointsFactory,
createConfig,
} from "express-zod-api";
// code
const getFeatures = defaultEndpointsFactory.build({
method: "get",
output: z.any().array(),
handler: async () => {
const features = new FeatureService();
const featureList = await features.list();
return featureList;
},
}); The type error:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
const getFeatures = defaultEndpointsFactory.build({
method: "get",
input: z.object({}),
output: z.object({
features: z.any().array(),
}),
handler: async () => {
const features = new FeatureService();
const featureList = await features.list();
return {
features: featureList
};
},
}); I would like to be able to write Another weird behavior: why |
Beta Was this translation helpful? Give feedback.
-
Hello @Aymericr . Thank you for reaching out. Regarding arraysThis is not a bug, it's intentionally made that way to encourage developers to always operate objects, as a best practice, since objects can evolve preserving the backward compatibility. Regarding instanses
Currently this is not possible, since Regarding inputs
If your endpoint does not have any inputs, you need to write I hope I managed to answer all your questions. |
Beta Was this translation helpful? Give feedback.
-
Now supporting array response: #361 (comment) |
Beta Was this translation helpful? Give feedback.
Now supporting array response: #361 (comment)
(at your own risk)