mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Move listings to their own directory
This commit is contained in:
parent
1b0b427a03
commit
2d7ab15978
1 changed files with 13 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import fs from 'fs-extra'
|
||||||
import has from 'just-has'
|
import has from 'just-has'
|
||||||
import test from 'ava'
|
import test from 'ava'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
@ -33,7 +34,18 @@ test.before(async t => {
|
||||||
t.context.listings = await Promise.all(
|
t.context.listings = await Promise.all(
|
||||||
listings.map(async listing => {
|
listings.map(async listing => {
|
||||||
const { endpoint } = listing
|
const { endpoint } = listing
|
||||||
const { data } = await axios.get(`${ process.env.PUBLIC_API_DOMAIN }/api${ endpoint }.json`)
|
|
||||||
|
const apiPath = `/api${ endpoint }.json`
|
||||||
|
const localPath = `./static/api${ endpoint }.json`
|
||||||
|
|
||||||
|
// Check if the endpoint exists locally
|
||||||
|
// so we don't have to wait for the API
|
||||||
|
if ( await fs.pathExists( localPath ) ) {
|
||||||
|
console.log('Using local endpoint data for', endpoint)
|
||||||
|
return await fs.readJson( localPath )
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await axios.get(`${ process.env.PUBLIC_API_DOMAIN }${ apiPath }`)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue