Skip to content

Commit 04632c4

Browse files
committed
Added proxy
1 parent 71bd4ae commit 04632c4

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

components/Map/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export default {
189189
}
190190
},
191191
mounted() {
192-
if (process.env.accessToken) this.createMap(process.env.accessToken)
192+
if (process.env.MAPBOX_TOKEN) this.createMap(process.env.MAPBOX_TOKEN)
193193
}
194194
}
195195
</script>

nuxt.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ module.exports = {
1010
** Environment variables
1111
*/
1212
env: {
13-
accessToken: process.env.MAPBOX_TOKEN,
14-
ga: process.env.GA
13+
HOST: process.env.HOST,
14+
PORT: process.env.PORT,
15+
MAPBOX_TOKEN: process.env.MAPBOX_TOKEN,
16+
GA: process.env.GA
1517
},
1618

1719
/*

openapi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"openapi":"3.0.2","info":{"title":"Coronavirus Tracker","description":"API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak. Project page: https://github.com/ExpDev07/coronavirus-tracker-api.","version":"2.0.1"},"paths":{"/v2/latest":{"get":{"tags":["v2"],"summary":"Get Latest","description":"Getting latest amount of total confirmed cases, deaths, and recoveries.","operationId":"get_latest_v2_latest_get","parameters":[{"required":false,"schema":{"title":"Source","enum":["jhu","csbs"],"type":"string","default":"jhu"},"name":"source","in":"query"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LatestResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v2/locations":{"get":{"tags":["v2"],"summary":"Get Locations","description":"Getting the locations.","operationId":"get_locations_v2_locations_get","parameters":[{"required":false,"schema":{"title":"Source","enum":["jhu","csbs"],"type":"string","default":"jhu"},"name":"source","in":"query"},{"required":false,"schema":{"title":"Country Code","type":"string"},"name":"country_code","in":"query"},{"required":false,"schema":{"title":"Province","type":"string"},"name":"province","in":"query"},{"required":false,"schema":{"title":"County","type":"string"},"name":"county","in":"query"},{"required":false,"schema":{"title":"Timelines","type":"boolean","default":false},"name":"timelines","in":"query"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LocationsResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v2/locations/{id}":{"get":{"tags":["v2"],"summary":"Get Location By Id","description":"Getting specific location by id.","operationId":"get_location_by_id_v2_locations__id__get","parameters":[{"required":true,"schema":{"title":"Id","type":"integer"},"name":"id","in":"path"},{"required":false,"schema":{"title":"Source","enum":["jhu","csbs"],"type":"string","default":"jhu"},"name":"source","in":"query"},{"required":false,"schema":{"title":"Timelines","type":"boolean","default":true},"name":"timelines","in":"query"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LocationResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v2/sources":{"get":{"tags":["v2"],"summary":"Sources","description":"Retrieves a list of data-sources that are availble to use.","operationId":"sources_v2_sources_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"HTTPValidationError":{"title":"HTTPValidationError","type":"object","properties":{"detail":{"title":"Detail","type":"array","items":{"$ref":"#/components/schemas/ValidationError"}}}},"Latest":{"title":"Latest","required":["confirmed","deaths","recovered"],"type":"object","properties":{"confirmed":{"title":"Confirmed","type":"integer"},"deaths":{"title":"Deaths","type":"integer"},"recovered":{"title":"Recovered","type":"integer"}}},"LatestResponse":{"title":"LatestResponse","required":["latest"],"type":"object","properties":{"latest":{"$ref":"#/components/schemas/Latest"}}},"Location":{"title":"Location","required":["id","country","country_code","last_updated","coordinates","latest"],"type":"object","properties":{"id":{"title":"Id","type":"integer"},"country":{"title":"Country","type":"string"},"country_code":{"title":"Country Code","type":"string"},"county":{"title":"County","type":"string","default":""},"province":{"title":"Province","type":"string","default":""},"last_updated":{"title":"Last Updated","type":"string"},"coordinates":{"title":"Coordinates","type":"object"},"latest":{"$ref":"#/components/schemas/Latest"},"timelines":{"title":"Timelines","allOf":[{"$ref":"#/components/schemas/Timelines"}],"default":{}}}},"LocationResponse":{"title":"LocationResponse","required":["location"],"type":"object","properties":{"location":{"$ref":"#/components/schemas/Location"}}},"LocationsResponse":{"title":"LocationsResponse","required":["latest"],"type":"object","properties":{"latest":{"$ref":"#/components/schemas/Latest"},"locations":{"title":"Locations","type":"array","items":{"$ref":"#/components/schemas/Location"},"default":[]}}},"Timeline":{"title":"Timeline","required":["latest"],"type":"object","properties":{"latest":{"title":"Latest","type":"integer"},"timeline":{"title":"Timeline","type":"object","additionalProperties":{"type":"integer"},"default":{}}}},"Timelines":{"title":"Timelines","required":["confirmed","deaths","recovered"],"type":"object","properties":{"confirmed":{"$ref":"#/components/schemas/Timeline"},"deaths":{"$ref":"#/components/schemas/Timeline"},"recovered":{"$ref":"#/components/schemas/Timeline"}}},"ValidationError":{"title":"ValidationError","required":["loc","msg","type"],"type":"object","properties":{"loc":{"title":"Location","type":"array","items":{"type":"string"}},"msg":{"title":"Message","type":"string"},"type":{"title":"Error Type","type":"string"}}}}}}

store/actions.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
export default {
22
async nuxtServerInit({ commit }, ctx) {
3-
await Promise
4-
.all([
5-
this.$axios.get(process.env.NODE_ENV !== 'production' ? 'latest.json' : '/api/latest'),
6-
this.$axios.get(process.env.NODE_ENV !== 'production' ? 'locations.json' : '/api/locations')
7-
])
3+
await Promise.all([
4+
this.$axios.get(
5+
process.env.NODE_ENV !== 'production'
6+
? 'latest.json'
7+
: `http://${process.env.HOST}:${process.env.PORT}/api/latest`
8+
),
9+
this.$axios.get(
10+
process.env.NODE_ENV !== 'production'
11+
? 'locations.json'
12+
: `http://${process.env.HOST}:${process.env.PORT}/api/locations`
13+
)
14+
])
815
.then(res => {
916
commit('SET_LATEST', res[0].data.latest)
1017
commit('SET_DATA', res[1].data)
@@ -17,7 +24,9 @@ export default {
1724
async getOverviewByCountry({ commit }, id) {
1825
await this.$axios
1926
.get(
20-
process.env.NODE_ENV !== 'production' ? 'location-16.json' : `/api/locations/${id}`
27+
process.env.NODE_ENV !== 'production'
28+
? 'location-16.json'
29+
: `http://${process.env.HOST}:${process.env.PORT}/api/locations/${id}`
2130
)
2231
.then(res => {
2332
if (res.status === 200) {

0 commit comments

Comments
 (0)