From 96173a79c4a4e57ff1ed30a6221ca81f6b847bd1 Mon Sep 17 00:00:00 2001 From: Martin Murphy Date: Mon, 6 May 2024 21:27:25 -0500 Subject: [PATCH 1/5] Add State Filter Add Proxy to CNP methods Support Local Stores Query with distance --- lib/server.js | 42 +- massage.js | 9 +- package-lock.json | 12813 +++++++++++++++++++++------------- src/components/Explorer.vue | 106 +- src/components/Header.vue | 5 +- 5 files changed, 8207 insertions(+), 4768 deletions(-) diff --git a/lib/server.js b/lib/server.js index a00868b..0c27f6c 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1,3 +1,4 @@ +require('dotenv').config() const express = require('express'); const fs = require('fs'); const quote = require('regexp-quote'); @@ -8,6 +9,7 @@ const renderer = require(appPath).default; const pageSize = 20; const versionFile = `${__dirname}/../version.txt`; const version = fs.existsSync(versionFile) ? fs.readFileSync(versionFile, 'utf8') : '0'; +const axios = require('axios'); // Disabled for now because it causes confusion when we update the data // const cache = {}; @@ -21,6 +23,33 @@ module.exports = async function({ plants, nurseries }) { } app.use(express.static(publicDir)); app.use('/images', express.static(`${__dirname}/../images`)); + app.use(express.json()) + + app.post('/get-vendors', async(req, res) =>{ + const baseUrl = process.env.PAC_API_BASE_URL + const apiKey = process.env.PAC_API_KEY + const url = `${baseUrl}/Plant/FindVendorsForPlantName?plantName=${req.body.plantName}&zipCode=${req.body.zipCode}&radius=${req.body.radius}&limit=5`; + var response = await axios.get(url, {headers: {'Authorization': 'Bearer ' + apiKey}}) + return res.send(response.data) + }) + app.post('/get-city', async(req, res)=> { + //console.log(req.params) + //call vendor/FindZip + const baseUrl = process.env.PAC_API_BASE_URL + const apiKey = process.env.PAC_API_KEY + const url = `${baseUrl}/vendor/FindCity?zipCode=${req.body.zipCode}`; + var response = await axios.get(url, {headers: {'Authorization': 'Bearer ' + apiKey}}) + return res.send(response.data) + }) + app.post('/get-zip', async(req, res)=> { + //console.log(req.params) + //call vendor/FindZip + const baseUrl = process.env.PAC_API_BASE_URL + const apiKey = process.env.PAC_API_KEY + const url = `${baseUrl}/vendor/FindZip?lat=${req.body.latitude}&lng=${req.body.longitude}`; + var response = await axios.get(url, {headers: {'Authorization': 'Bearer ' + apiKey}}) + return res.send(response.data) + }) app.get('/api/v1/plants', async (req, res) => { try { const fetchResults = req.query.results !== '0'; @@ -92,6 +121,11 @@ module.exports = async function({ plants, nurseries }) { heights.push(i); } const filters = [ + { + name: 'States', + value: [], + array: true + }, { name: 'Sun Exposure Flags', value: [], @@ -364,18 +398,18 @@ module.exports = async function({ plants, nurseries }) { - + - + - + - Choose Native Plants PA + Choose Native Plants