Skip to content

dali-lab/grazing-earth-backend

Repository files navigation

Grazing Earth

Backend for the Grazing Earth mobile app.

Tech Stack

Directory Structure

.
├── ...         
├── src                    
|   └── auth                # JWT middleware
|   └── controllers         # dispatch input; output
|   └── db                  # PostgreSQL database definitions
|     └── config            # define database modes
|     └── migrations        # Sequelize migrations
|     └── models            # defines structure of PostgreSQL tables
|     └── seeders           # code to populate database with initial data
|   └── errors              # internal error handling
|   └── routers             # route url endpoint
|     └── __tests__         # test cases for routers
|   └── services            # handles database queries and related functionality
|     └── __tests__         # test cases for services
|   └── validation          # validates input w/ joi
|   └── constants.ts        # server constants
|   └── server.ts           # starting point of server
└── ...

Setup

  1. clone repo and npm install
  2. Install PostgreSQL + management tool
  • Make sure to do npm install --save-dev sequelize-cli if you don't have the sequelize cli yet.
  • Windows
  • MacOS
    • Ensure Homebrew is installed
    • Run brew install postgresql if PostgreSQL isn't installed
    • If you'd like to use a GUI to interact with PostgreSQL, download one. We recommend Postico
  1. Create a PostgreSQL DB called grazing_earth if setting up locally, using your GUI of choice (Postico or pgAdmin).
  2. Create a .env file in the root directory
  • Should be in the following format:
  • AUTH_SECRET=*secret assortment of characters used for encryption*
    PORT=4000
    DATABASE_URL=postgres://username:password@localhost:5432/grazing_earth
    AWS_ACCESS_KEY_ID=*see credentials doc*
    AWS_SECRET_ACCESS_KEY=*see credentials doc*
    S3_BUCKET_NAME=*see credentials doc*
    SENDGRID_EMAIL=*see credentials doc*
    SENDGRID_API_KEY=*see credentials doc*
    DEBUG=true
    
  1. Run npx sequelize db:migrate to apply migrations to DB.
  2. Run npx sequelize db:seed:all to load initial data.
  3. App should be ready for use now
  • npm start to run in production mode
  • npm run dev to run with hot reloading

Redux Debugging

Download the Redux DevTools extension.

Linting

ESLint is set up in this project. To keep code clean, always remember to run npm run lint and fix any lint problems before merging into master.

Unit Testing

Jest unit testing is set up for the controllers, routers, and services. Remember to run npm test and fix any breaking changes that might've occured.

  • You can also run just an individual test file with npm test -- *filename*

Authors & Credits

  • Eric Lu '25

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •