/backend

Your one stop shop for finding farmer's markets

Primary LanguageJavaScriptMIT LicenseMIT

KitchenFarmr

Table of Contents

Makefile Commands

stop: Stop the running server

rm: Remove all unused containers

rm-all: Stop and remove all containers

rmi: Remove stockstalker images without removing base images. Useful for speeding up build time when switching from one start script to another such as make start to make test

rmi-all: Remove all images

purge: Use with caution Completely purge Docker containers, networks, images, volumes, and cache

lint: Run eslint

build: Build development server without running the server

start: Start development server at port 5000

reload: Stop development server and restart the server at port 5000

hard-reload: Stop container, remove container, rebuild container, and start development server

debug: Start development server in debug mode

test: Start test server

reload-test: Reload test server

hard-reload-test: Stop container, remove container, rebuild container, and start test server

Required Software

How to Run

Clone the repo

git clone git@github.com:KitchenFarmr/KitchenFarmr.git

cd into the directory

cd KitchenFarmr

Rename .env.sample to .env

mv .env.sample .env

Edit the .env file to contain your environment variables

vim .env

Run the application!

make start

To stop the app press CNTRL + C. Then run:

make stop

How to Contribute

Branches

Production should never be directly modified. Please make a new branch for every feature/bugfix. The branch naming should follow the protcol:

feature/name-of-new-feature
bugfix/short-description-of-bugfix

Example:

feature/create-home-route

Commits

Title

Commit titles should follow the following syntax:

"[command] name-of-file"

Where command is one of:

  • create
  • update
  • delete
  • lint

Body

The body should describe what actually happened. It should be written in the present tense.

Example:

"Create homepage route located at path / to return, Hello World"

Commit

Below are some examples of full commits:

git commit -m "[create] homepage route" -m "Create homepage route located at path / to return, Hello World"
git commit -m "[delete] test.js" -m "Broke up test.js into testAuth.js and testCheckout.js"

Pull Requests

Upon completing the feature/bugfix of the corresponding branch create a pull request with a title and description. Add at least one code reviewer to the pull request to ensure good code quality and practice. Once the code has been approved by both the reviewer and the test pipeline. The code will be merged into production.

API Documentation

Base URL

http://165.232.159.127/

Get Nearby Markets

Request

GET /results/:zipcode

Response

Success status code: 200

This route returns a list of farmers markets based on distance from the provided zipcode.

Example response (for zipcode 12345):

[
    {
        "id": "1018381",
        "marketname": "Clifton Park Farmers' Market",
        "GoogleLink": "http://maps.google.com/?q=42.869606%2C%20-73.809271%20(%22Clifton+Park+Farmers'+Market%22)",
        "Products": [
            "Baked goods",
            "Cut flowers",
            "Eggs",
            "Fresh fruit and vegetables",
            "Honey",
            "Canned or preserved fruits, vegetables, jams, jellies, preserves, salsas, pickles, dried fruit, etc.",
            "Maple syrup and/or maple products",
            "Meat",
            "Prepared foods (for immediate consumption)"
        ],
        "distance_from_zip": "7.7",
        "street": "971 Route 146",
        "city": "Shenendehowa United Methodist Church parking lot ",
        "state": "Clifton Park",
        "zipcode": "New York",
        "yearly_schedule": "06/04/2018 to 10/29/2018",
        "weekly_schedule": "Mon: 2:00 PM-5:00 PM"
    },
    {
        "id": "1001925",
        "marketname": "Voorheesville Farmers Market",
        "GoogleLink": "http://maps.google.com/?q=42.649656%2C%20-73.930027%20(%22Voorheesville+Farmers+Market%22)",
        "Products": [
            "Baked goods",
            "Cut flowers",
            "Eggs",
            "Fresh fruit and vegetables",
            "Fresh and/or dried herbs",
            "Honey",
            "Maple syrup and/or maple products",
            "Plants in containers",
            "Prepared foods (for immediate consumption)",
            "Soap and/or body care products"
        ],
        "distance_from_zip": "11.5",
        "street": "68 Maple Ave.",
        "city": "Voorheesville",
        "state": "New York",
        "zipcode": "12186",
        "yearly_schedule": "06/16/2021 to 06/16/2021",
        "weekly_schedule": "Wed: 3:30 PM-6:30 PM"
    },
    ...
]

Running Tests

To run tests simple run:

make test

If any of the tests fail or if the tests do not have at least 90% coverage the command will exit with a status code of 1.