Protofy-xyz / Protofy

AI Supercharged LowCode Platform CMS and Framework 🚀🚀
https://protofy.xyz/
MIT License
235 stars 49 forks source link

Add TypeScript-Friendly API Support to Enable Usage in TypeScript (.ts) Files #25

Closed jjjorgina closed 9 months ago

jjjorgina commented 9 months ago

Problem/Need To Be Solved

The current protofy starter project provides a JSX generic API for frontend (React) usage exported in Protolib Package. However, there's a need to extend its functionality to include a TypeScript-friendly generic API for backend usage. This feature request aims to address this need. This feature request does not aim to replace or remove the existing JSX generic API but rather to complement it with TypeScript support.

Solution Suggestion

Additional resources

We find out that protolib's exported API is not compatible with IoT Router Api template. This is the current protolib package API file:

https://github.com/Protofy-xyz/Protofy/blob/main/packages/protolib/base/Api.ts

gdomenech98 commented 9 months ago

The protolib library exports React components in its default export file (index.tsx). When you use the protolib library in a backend application (such as apps/api, which is an ExpressJS app), it's unable to compile React components.

To circumvent this issue, you should specify a more specific path to your component, ensuring that the default export file in that subdirectory (N level deep) does not export any React components.

eg. ✅ import { Protofy } from "protolib/base"import { Protofy } from "protolib").