game-village-politics-frontend/app/plugins/networking.ts

15 lines
574 B
TypeScript
Raw Normal View History

export default defineNuxtPlugin((nuxtApp) => {
const config = useRuntimeConfig().public
const notices = useNotices()
setupNetworking({
serverUrl: String(config.SERVER_URL),
wsUrl: `${config.WS_PROTOCOL === 'ws' ? 'ws' : 'wss'}://${config.WEBS_URL}/app/${config.PUSHER_APP_KEY}`,
appKey: String(config.PUSHER_APP_KEY),
mock: String(config.MOCK_SERVER) === 'true',
notify: (opts, type) =>
typeof opts === 'string' ? notices.push(opts, type ?? 'info') : notices.push(opts.text, opts.type),
translate: (key) => nuxtApp.$i18n.t(key),
})
})