Bob-s-Fullstack-Builders / open-code-harmony

We'll make our own CodeWars! With solution sharing and learning as a focus!
MIT License
0 stars 0 forks source link

Create local dev script #5

Closed JimOfLeisure closed 2 years ago

JimOfLeisure commented 2 years ago

I currently plan for the completed site to have front end code and at least one API all appearing to be at the same domain and port. So we're going to need a build script to set up a dev server to handle that routing when testing locally.

I can think of a couple of possible ways, but a little research and experimentation may be needed.

On second thought, maybe it's as simple as moving the frontend to an express.static() folder inside the API and only enable the static folder if process.env.PORT is not present, meaning when running locally the static folder serves the frontend but when on Heroku or similar it does not.

JimOfLeisure commented 2 years ago

Ok, yeah, we can deploy the static site from api-submission/public as easily as we could frontend/ , and we could then even add a deploy-static script using environment variables for secrets and hosting targets.

Come to think of it we'll probably have all the APIs in that one express server, too, and we can manage cacheability with headers when it comes to that.

JimOfLeisure commented 2 years ago

The repo was refactored, and frontend is now under server/frontend and is conditionally static-served by express. Also, dev scripts are added for server/ .

see commit 9dc930afce2c00404324baa2f0e33a50f1c5be26