DEV Community

Cover image for Day 2 | Xhopie - Starting up
Manish
Manish

Posted on

Day 2 | Xhopie - Starting up

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 and EXAMPLE_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.
  • 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 of process.env
    • used inheritance to automatically extend from the ENV_Variables interface.
  • defined a separate APP_CONFIG variable in config 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

Refactoring The Project's Folder Structure

  • added the src folder.
    • made corresponding updates in the package.json as well as tsconfig.json

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)