Back

Any Types for Appwrite Functions?

  • 0
  • Functions
Mittelblut9
16 Oct, 2024, 08:20

In the templates there are always "any" as type... But is there any type declaration that i can use?

(And i don't want to write a whole type from scratch)

Edit: I tried the http types, but than the res.json is not valid. And i tried the express types, but than the res.status throws an error in appwrite

TypeScript
export default async ({ req, res, log, error }: {
req: someType;
res: someType;
log: (msg: any) => void;
error: (msg: any) => void;
}) => {}
TL;DR
Developers want to know if there are type declarations they can use for Appwrite Functions instead of using "any" type. They tried using HTTP types and Express types, but encountered issues with res.json and res.status. Solution: Developers can specify a more specific type for req and res such as Express's `Request` and `Response` types without needing to write a whole type from scratch. ```js export default async ({ req, res, log, error }: { req: Express.Request; res: Express.Response; log: (msg: any) => void; error: (msg: any)
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more