Context
This is a blog series where I document my progress on Xhopie, a self project I'm starting to learn about general concepts regarding software development by implementing an e-commerce application with different tools and technologies to learn how to do important and common things in different languages.
Here's the main repo link: https://github.com/the-halfbloodprince/xhopie-main
Work Overview
So here is a brief overview of the work
on xhopie-server-node
Environment Variables
- added env file support (used dotenv, considered also using the native
--env-file
flag of NodeJS, but fell back on dotenv to make it work asap with nodemon and ts-node)- currently just added
PORT
,HOST
andEXAMPLE_VARIABLE
to the list -
EXAMPLE_VARIABLE
is just a variable used to be available to confirm the proper loading of env variables. This can be done in other more robust ways probably, or just by checking any other variable, so it is safe to be removed in a future commit. - added all of them in an
.env.example
file as well.
- currently just added
- added env file type declaration support
- added a
ENV_Variables
interface in the config folder for declarations of the variables - added a overwrite of
ProcessEnv
interface which declares the interface ofprocess.env
- used inheritance to automatically extend from the
ENV_Variables
interface.
- added a
- defined a separate
APP_CONFIG
variable inconfig
folder to hold important app wide accessible variables in one place- added the env variables present at the moment to
APP_CONFIG
- also throwing an error if there was any error in loading env variables.
- TODO: This should be properly handled later instead of blatantly just throwing an error
- also this makes the purpose of
EXAMPLE_HANDLING
obsolete, so it's been removed
- added the env variables present at the moment to
Refactoring The Project's Folder Structure
- added the
src
folder.- made corresponding updates in the
package.json
as well astsconfig.json
- made corresponding updates in the
It was a short day, mostly just configuring stuff up, recalling the good architectural/folder patterns etc, and just brushing up some of my old concepts and memories.
Hope you hadn't given up on your new year resolutions yet. Keep the work up.
See you on the next day.
Top comments (0)