jacksloan / prisma-proxy

Create type-safe proxy servers/clients for Prisma
MIT License
5 stars 2 forks source link

prisma-proxy-fetch-client #8

Closed mkuchak closed 2 years ago

mkuchak commented 2 years ago

The version 0.0.8 has a small problem and is not working. The package published on NPM for this release has the index.js file, but the package.json is reading the index.min.js, so the library is not initialized.

--

Another issue: sometimes Prisma returns undefined and the library throws an error. Maybe it's better to fix it to not throw error with undefined because that's normal during everyday use.

      try {
         // null is a valid prisma response for some queries
-        return text === null ? text : JSON.parse(text);
+        return text && JSON.parse(text);
       } catch (e) {

--

It would be nice to have a fix. By the way, cool project, it's helping me build a template with Cloudflare Workers. Very thanks! :)

jacksloan commented 2 years ago

Thanks, @mkuchak, for digging in. Your fork looks good to me if you want to make a PR from that.

mkuchak commented 2 years ago

Hey! I redid the PR only with the necessary changes for the correct functioning of the two libraries.

prisma-proxy-express-server also has a little problem sending the response which should be in JSON.

     ][prismaAction];
-    prismaFunc(prismaArgs).then((data: any) => res.send(data));
+    prismaFunc(prismaArgs).then((data: any) => res.json(data));
   });

As it currently stands some ORM calls like const totalUsers = await prisma.user.count() don't work.

With the PR everything should work correctly.

jacksloan commented 2 years ago

Great work, looks good to me! Thanks for taking the time to use the library and discover some edge cases I hadn't considered.

jacksloan commented 2 years ago

published in 0.0.9