Skip to content

The Backend for a logistics application handling consignment dimensioning and shipping

Notifications You must be signed in to change notification settings

IIT-Patna-Inter-IIT-Tech-Meet/grow-simplee-backend

Repository files navigation

Grow Simplee Backend

Before Running (Prerequisites)

  • Install node_modules, by running the following command (Note: package manager used for this project is yarn)

    yarn install
  • Create a .env file, with the following contents:

    PORT=5000
    CLIENT_URL=<enter the client url>
    APP_URL=<enter the app client url>
    NODE_ENV='development' # would be subject to change.
    
    # Database settings
    DATABASE_URL='mysql://<url-encoded USERNAME>:<url-encoded PASSWORD>@<HOSTNAME>:<PORT>/<DATABASE>'
    
    # JWT secret
    TOKEN_SECRET=<super secret something>
    
    # Mailing credentials
    MAILING_EMAIL=<mailing email>
    MAILING_PASSWORD=<mailing password>
    
    # Super Admin credentials
    SUPER_ADMIN_EMAIL=<super-admin email>
    SUPER_ADMIN_PASSWORD=<super-admin password>
    
    # Redis DB URL
    REDIS_URL=<redis db url>
    
    # Google maps API
    GOOGLE_MAPS_API_KEY=<google-maps api key>
  • Install the Redis server.

    • USE THE FOLLOWING WAY TO START REDIS SERVER (Platform independent).

      $ docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest
    • For Debian-based Linux distributions, the following command should do:
      sudo apt install redis-server
    • For macOS users, with homebrew installed:
      brew install redis-server
    • For Windows users, since there doesn't seem to be any support. You might wanna install WSL2. Refer this.
  • Install MySQL server and MySQL Workbench.

  • Create Database as per the URI set in the env

  • Apply migrations to database by running the following command:

    yarn run prisma migrate dev

Before commiting:

  • Run the following command:

    $ yarn run fmt
    $ yarn run fmt-check
    $ yarn run lint
  • Please ensure that above commands return with exit-code 0. (PS: warnings from eslint are acceptable)

How to run?

  • Basic
    yarn run start
  • For development
    yarn run dev

Database (MySQL with Prisma for Database handling)

  1. Make sure that you have populated the DATABASE_URL environment variable in your .env file with a valid URL.
  2. Populate the file prisma/schema.prisma with appropriate models.
  3. Run the following command:
    yarn run prisma migrate dev --name <NAME>
    Here NAME is the name of the migration you wish to give.
  4. The above command takes care of 2 things:
    • Makes appropriate changes to the database.
    • generates @prisma/client which has typing and functions for each model as ORM.
  5. Make sure that SUPER_ADMIN_EMAIL and SUPER_ADMIN_PASSWORD exist as environment variables, they act as the credentials for logging in as the super admin.

Conventions you might wanna abide by.

  • Use kebab-case for URL paths.

    • Undesirable Examples:
      • /user/forgotPassword
      • /User/Forgot-Password
      • /get_User_Details
    • Acceptable Examples:
      • /user/forgot-password
      • /get-user-details

About

The Backend for a logistics application handling consignment dimensioning and shipping

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published