Skip to content

Commit

Permalink
Remove need for stac retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBroersma committed Nov 23, 2023
1 parent e57f3e2 commit c5eff39
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
6 changes: 1 addition & 5 deletions app/server/routes/stac/[...].ts → App/dev/stac/[...].ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ export default defineEventHandler(async (event) => {

if (!path) throw new Error('No path provided')

let json = await fs.readFile(
process.env.NODE_ENV === 'development'
? `${process.cwd()}/../STAC/data/current/${path}`
: `${process.cwd()}/public/stac/${path}`,
)
let json = await fs.readFile(`${process.cwd()}/../STAC/data/current/${path}`)

return json
})
9 changes: 9 additions & 0 deletions app/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ export default defineNuxtConfig({
noExternal: ['vuetify'],
},
},
serverHandlers:
process.env.NODE_ENV === 'development'
? [
{
route: '/stac/**',
handler: '~/dev/stac/[...].ts',
},
]
: [],
})
13 changes: 8 additions & 5 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ type ItemType = typeof itemShape
type CatalogType = typeof catalogShape
type CollectionType = typeof collectionShape
let url = useRequestURL()
let {
public: { mapboxToken, stacRoot },
public: { mapboxToken },
} = useRuntimeConfig()
let catalogPath = `${stacRoot}/catalog.json`
let baseURL = url.protocol + '//' + url.host + '/stac'
let catalogPath = `${baseURL}/catalog.json`
let { data: catalogJson } = await useFetch<CatalogType>(catalogPath)
Expand All @@ -26,7 +30,7 @@ let collections = (
await Promise.all(
childrenLinks.map(async (childLink) => {
let { data } = await useFetch<CollectionType>(
`${stacRoot}/${childLink.href}`,
`${baseURL}/${childLink.href}`,
)
return data.value
}),
Expand Down Expand Up @@ -92,8 +96,7 @@ let activeItemUrl = computed(() => {
})
let { data } = await useAsyncData(
() =>
$fetch(`${stacRoot}/${activeCollectionId.value}/${activeItemUrl.value}`),
() => $fetch(`${baseURL}/${activeCollectionId.value}/${activeItemUrl.value}`),
{ watch: [activeItemUrl] },
)
Expand Down

0 comments on commit c5eff39

Please sign in to comment.