Common files library between server and application

Hello,

We use Freshdesk with a custom application. It work with both client and serverless part . Client and sever have code in common. We want to mutualize it in a same directory.

Actually we have the following file structure:

|FdProject 
|-- App 
|   |-- js 
**|   |-- common **
**|       |-- somelib.js **
**|       |-- someotherlib.js** 
|   |-- css 
|   |-- templates 
|   |-- … 
|   |-- app.js 
|-- Server 
|   |-- lib 
**|   |-- common **
**|       |-- somelib.js **
**|       |-- someotherlib.js** 
|   |-- … 
|   |-- server.js 
 
And we want: 
|-- App 
|   |-- js 
|   |-- css 
|   |-- templates 
|   |-- … 
|   |-- app.js 
|-- Server 
|   |-- lib 
|   |-- … 
|   |-- server.js 
**|-- common   # <-- move common directory one level up **
**|   |-- somelib.js **
**|   |-- someotherlib.js**

This common directory must exists once in source, and should be set up in application and in server part on packing time.
What is the best practice to make a common source directory, having common code between app and server without any code replication ?

Thank for your help.

Hey @yranek,

Welcome to Freshworks Developer Community! :tada:

The app source code structure is strictly organized into app and server which resonates with the Front-end and Serverless components of the app and cannot be modified. However, you can use library files and they are in the following path -
Front-end: app/library
Serverless: /server/lib/

Take a look at External Libraries where you can use Front-end libraries and if your serverless component’s lib files are available over NPM public registry you can import them, making your app’s code more optimized.

Wanted to understand from you the kind of common lib.js files shared between front-end and serverless.

Let me know if there is anything I can help you with.

Hello,

Thank for your support. I understand what shared repository is not possible yet.
The external libraries seem good, but implies the use of the public registry. The shared code we want is proper to our custom app.

We probably have to improve our build tools chain to replicate the directory in app and server library.

Thanks you.

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.