How to structure static javascript files in Node.js (Express) + Typescript application and what is the right way of using environment variables?

Viewed 15

I am working on a Node.js (Express) + TypeScript application which implements the MVC pattern. This is how my project directory looks like

.
├── dist/
├── LICENSE
├── package.json
├── package-lock.json
├── public/
├── README.md
├── src/
│   ├── app.ts
│   ├── controllers/
│   ├── routes/
│   └── views/
└── tsconfig.json

Now, I know I can put all the static files like all the JS files for the client-side inside the public folder but that is if I am writing my application in JS. As I mentioned, I am using TypeScript for this application and want to write my client-side logic using TypeScript. But I don't know, for example, what should be the folder structure inside the src directory and also If I am marking the public folder (which is outside the dist folder) as static using express.static(), how can I tell the TS compiler to move the files for client-side code to the public/js directory, instead of putting it inside the src directory along with the server-side code.

0 Answers
Related