shared scripts between client and server #9298
-
Hi, I'm new to quasar, I'm experimenting with creating an app with rest api using ssr (you know if that's a good idea?) And typescript. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
The ssr server Quasar uses is not for hosting/creating a API endpoints. It's just for server side rendering. For an api rest server you need to use something like Express. Quasar is frontend only. A way to codeshare between Express(or any nodejs based server) and Quasar you could put the Express project folder inside of Quasar's project folder, for example `my_quasar_project_folder/api'. That way Quasar can import js files from you server in the 'api' folder. |
Beta Was this translation helpful? Give feedback.
-
I've found the best way to share code like this, is to create a yarn workspace and set up 3 folders: client, backend, and shared. |
Beta Was this translation helpful? Give feedback.
-
if u wanna u backend to be served from the same process of your frontend, u can follow that strategy. the advantage here, u can decouple the backend from the frontend at anytime. |
Beta Was this translation helpful? Give feedback.
-
In Quasar v2 you can use a SSR Middleware to hook your API too. https://next.quasar.dev/quasar-cli/developing-ssr/ssr-middleware#anatomy-of-a-middleware-file |
Beta Was this translation helpful? Give feedback.
I've found the best way to share code like this, is to create a yarn workspace and set up 3 folders: client, backend, and shared.