Move test API host to env. Add plugin as import.

This commit is contained in:
Tom Southall
2022-04-02 12:55:19 +01:00
parent 7ddfdcdada
commit 941c25926e
3 changed files with 19 additions and 5 deletions

View File

@@ -9,9 +9,11 @@ import ItemContents from './components/itemContents/itemContents'
import GroupName from './components/groupName/groupName'
import CancelButton from './components/cancelButton/cancelButton'
import ClearButton from './components/clearButton/clearButton'
import recentSearchesPlugin from '../../plugins/turnstone-recent-searches'
import recentSearchesPlugin from 'turnstone-recent-searches'
import undef from '../../src/lib/utils/undef'
const apiHost = import.meta.env.VITE_API_HOST
console.log({apiHost})
const maxItems = 10
const placeholder = 'Enter a city or airport'
const noItemsMessage = 'We found no places that match your search'
@@ -23,7 +25,7 @@ const listbox = [
ratio: 8,
displayField: 'name',
data: (query) =>
fetch(`http://localhost:3001/api/search/cities?q=${encodeURIComponent(query)}&limit=${maxItems}`)
fetch(`${apiHost}/api/search/cities?q=${encodeURIComponent(query)}&limit=${maxItems}`)
.then(response => response.json()),
searchType: 'startswith'
},
@@ -33,7 +35,7 @@ const listbox = [
ratio: 2,
displayField: 'name',
data: (query) =>
fetch(`http://localhost:3001/api/search/airports?q=${encodeURIComponent(query)}&limit=${maxItems}`)
fetch(`${apiHost}/api/search/airports?q=${encodeURIComponent(query)}&limit=${maxItems}`)
.then(response => response.json()),
searchType: 'contains'
}

15
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "turnstone",
"version": "1.2.0",
"version": "1.2.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "turnstone",
"version": "1.2.0",
"version": "1.2.3",
"license": "MIT",
"dependencies": {
"escape-string-regexp": "^5.0.0",
@@ -16,6 +16,7 @@
"setify": "^1.0.4",
"split-match": "^0.2.2",
"swr": "^1.1.2",
"turnstone-recent-searches": "^0.4.0",
"use-debounce": "^7.0.1"
},
"devDependencies": {
@@ -5006,6 +5007,11 @@
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"node_modules/turnstone-recent-searches": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/turnstone-recent-searches/-/turnstone-recent-searches-0.4.0.tgz",
"integrity": "sha512-3/ejeRHv+awlU2mI6l3dFXmbvzCsi0KgEmbJ7AD/X50d0Eu7VbJXnoH5RsMU4rFuO6swPGMhsuTx5Dl48MyBLw=="
},
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@@ -9054,6 +9060,11 @@
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"turnstone-recent-searches": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/turnstone-recent-searches/-/turnstone-recent-searches-0.4.0.tgz",
"integrity": "sha512-3/ejeRHv+awlU2mI6l3dFXmbvzCsi0KgEmbJ7AD/X50d0Eu7VbJXnoH5RsMU4rFuO6swPGMhsuTx5Dl48MyBLw=="
},
"type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",

View File

@@ -52,6 +52,7 @@
"setify": "^1.0.4",
"split-match": "^0.2.2",
"swr": "^1.1.2",
"turnstone-recent-searches": "^0.4.0",
"use-debounce": "^7.0.1"
},
"devDependencies": {