import { createClient as createVendoClient } from 'db-vendo-client'; import { createClient as createHafasClient } from 'hafas-client'; import { profile as dbNavProfile } from 'db-vendo-client/p/dbnav/index.js'; import { profile as bvgProfile } from 'hafas-client/p/bvg/index.js'; import { profile as nahshProfile } from 'hafas-client/p/nahsh/index.js'; import { profile as rmvProfile } from 'hafas-client/p/rmv/index.js'; import { profile as oebbProfile } from 'hafas-client/p/oebb/index.js'; import { profile as rejseplanenProfile } from 'hafas-client/p/rejseplanen/index.js' const clients = {}; export let client; export const profiles = { db: { name: "DB", backend: 'vendo', profile: dbNavProfile }, bvg: { name: "BVG", backend: 'hafas', profile: bvgProfile }, nahsh: { name: "NAH.SH", backend: 'hafas', profile: nahshProfile }, rmv: { name: "RMV", backend: 'hafas', profile: rmvProfile }, oebb: { name: "ÖBB", backend: 'hafas', profile: oebbProfile }, rejseplanen: { name: "Rejseplanen", backend: 'hafas', profile: rejseplanenProfile }, } export const getDefaultProfile = () => 'db'; export const getHafasClient = async profileName => { if (!profiles[profileName]) throw "Unknown profile name: " + profileName; if (!clients[profileName]) { if (profiles[profileName].backend === 'vendo') { clients[profileName] = createVendoClient(profiles[profileName].profile, APP_NAME, {enrichStations: false}); if (isDevServer) console.info('initialized vendo client with profile ' + profileName); } if (profiles[profileName].backend === 'hafas') { clients[profileName] = createHafasClient(profiles[profileName].profile, APP_NAME); if (isDevServer) console.info('initialized hafas client with profile ' + profileName); } } return clients[profileName]; } export const initHafasClient = async profileName => { client = await getHafasClient(profileName); };