import { App, Plugin } from 'vue'; export class Advent22 { private get api_baseurl(): string { // in production mode, return "//host/api" if (process.env.NODE_ENV === "production") { return `//${window.location.host}/api`; } else if (process.env.NODE_ENV !== "development") { // not in prouction or development mode console.warn("Unexpected NODE_ENV value"); } // in development mode, return "//hostname:8000/api" return `//${window.location.hostname}:8000/api`; } public api_url(endpoint?: string): string { if (endpoint === undefined) return `${this.api_baseurl}`; return `${this.api_baseurl}/${endpoint}`; } } export const Advent22Plugin: Plugin = { install(app: App) { app.config.globalProperties.$advent22 = new Advent22(); } }