Skip to content
Snippets Groups Projects
Commit 9b508950 authored by Henrik Askjer's avatar Henrik Askjer
Browse files

Organize endpoints and add stage parameter

parent d93a1548
No related branches found
No related tags found
No related merge requests found
VUE_APP_API_PREFIX=
VUE_APP_SEARCH_ENDPOINT='https://oda.uib.no/opal/api/'
\ No newline at end of file
NODE_ENV=production
VUE_APP_API_PREFIX=
VUE_APP_API_STAGE=dev
VUE_APP_ARTICLE_ENDPOINT='https://oda.uib.no/opal/dev/'
\ No newline at end of file
VUE_APP_API_PREFIX=https://dev.ordbok.uib.no
VUE_APP_API_STAGE=dev
VUE_APP_ARTICLE_ENDPOINT='https://oda.uib.no/opal/dev/'
VUE_APP_VERSION_LABEL=LOCAL
VUE_APP_RELEASE=test
NODE_ENV=production
VUE_APP_VERSION_LABEL=Beta
VUE_APP_API_PREFIX=
VUE_APP_API_STAGE=prod
VUE_APP_ARTICLE_ENDPOINT='https://oda.uib.no/opal/prod/'
\ No newline at end of file
......@@ -75,26 +75,33 @@ import Autocomplete from './Autocomplete.vue'
import { setup } from 'axios-cache-adapter'
const SEARCH_ENDPOINT = process.env.VUE_APP_SEARCH_ENDPOINT
const ARTICLE_ENDPOINT= process.env.VUE_APP_ARTICLE_ENDPOINT
const API_STAGE = process.env.VUE_APP_API_STAGE
console.log(SEARCH_ENDPOINT)
console.log(ARTICLE_ENDPOINT)
console.log(API_STAGE)
const dicts = {'nob': 'Nynorskorboka',
'bob': 'Bokmålsordboka',
'bob,nob': 'ordbøkene'}
const oda_api = setup({
baseURL: 'https://oda.uib.no/opal/api/',
baseURL: SEARCH_ENDPOINT,
params: {stage: API_STAGE},
cache: {
maxAge: 15 * 60 * 1000,
exclude: {
query: false,
paths: ["articles"]
paths: ["articles"] // Disable caching for articles
}
}
})
const api_endpoint = process.env.VUE_APP_API_PREFIX + '/api/dict'
const oda_dev = 'https://oda.uib.no/opal/dev'
const dicts = {'nob': 'Nynorskorboka',
'bob': 'Bokmålsordboka',
'bob,nob': 'ordbøkene'}
function navigate_to_article(self, source) {
let config = {headers: {}}
......@@ -102,7 +109,7 @@ function navigate_to_article(self, source) {
if ((self.$route.query.nocache || '').toLowerCase() == 'true') {
config.headers.cachebuster = Date.now()
}*/
axios.get(oda_dev + '/' + self.$route.params.lang + '/article/' + self.$route.params.id + ".json", config)
axios.get(ARTICLE_ENDPOINT + self.$route.params.lang + '/article/' + self.$route.params.id + ".json", config)
.then(function(response){
self.article = Object.assign(response.data, {'dictionary': self.$route.params.lang, results: self.search_results})
self.search_results = []
......@@ -168,7 +175,7 @@ function navigate_to_query(self, word) {
// Get individual articles
Promise.all(unwrapped.map((article) => {
return axios.get(`${oda_dev}/${article.dictionary}/article/${article.id}.json`)
return axios.get(`${ARTICLE_ENDPOINT}${article.dictionary}/article/${article.id}.json`)
}))
.then((response) => {
......@@ -231,7 +238,7 @@ export default {
return (this.waiting_for_articles || this.waiting_for_metadata) && this.$route.name != 'root'
},
api_pref: function() {
return api_endpoint + '/' + this.lang + '/article/'
return ARTICLE_ENDPOINT + this.lang + '/article/'
},
get_oda_api: function() {
return oda_api
......@@ -298,11 +305,11 @@ export default {
this.lang = 'bob,nob'
Promise.all([
axios.get(oda_dev + '/nob/concepts.json').then(function(response){
axios.get(ARTICLE_ENDPOINT + 'nob/concepts.json').then(function(response){
let concepts = response.data.concepts
entities.bob = concepts
}),
axios.get(oda_dev + '/nob/concepts.json').then(function(response){
axios.get(ARTICLE_ENDPOINT + 'nob/concepts.json').then(function(response){
let concepts = response.data.concepts
entities.nob = concepts
})
......@@ -326,11 +333,11 @@ export default {
}
// words of the month
axios.get(oda_dev + '/bob/article/5607.json').then(function(response){
axios.get(ARTICLE_ENDPOINT + 'bob/article/5607.json').then(function(response){
self.monthly_bm = Object.assign(response.data, {dictionary: 'bob'})
})
axios.get(oda_dev + '/nob/article/78569.json').then(function(response){
axios.get(ARTICLE_ENDPOINT + 'nob/article/78569.json').then(function(response){
self.monthly_nn = Object.assign(response.data, {dictionary: 'nob'})
})
}).catch(function(_){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment