Quasar App Extension Blazar
This App Extension simplifies the access to Blazar's API, specially the auth zetas. It also injects a $socket
and $api
into the Vue instance.
Install
quasar ext add blazar
Quasar CLI will retrieve it from our Verdaccio registry and install the extension.
Configuration
This App Extensions reads the following process.env
values:
- BLAZAR_HOST
- BLAZAR_SECURE
- BLAZAR_PORT
So, it's recommended to set those values with dotenv:
quasar ext add @quasar/dotenv
the .env file:
BLAZAR_HOST=blazar-dev.purple.uno
BLAZAR_SECURE=true
BLAZAR_PORT=443
Prompts
NameSpace
This App Extension automatically sends this nameSpace to the Blazar backend. You can change it later on quasar.extensions.json
.
To send to a public zeta, use:
const res = await this
To send to a public nameSpaced zeta, use:
const res = await this
The body of the request should always be an object (other types are coerced to objects before sending anyway).
Uninstall
quasar ext remove blazar
Usage
Checkout the demo/src/pages/Index.vue
for an usage example. Basically:
// then, just call the functions somewhere in your code:blazar blazar blazar blazar blazar
All functions returns promises.
You can also import the api
method in /store/index.js
like this:
// no body neededconst res = await blazar // with body:const res = await blazar
You can access the Blazar backend like this:
// your Vue component script: methods: { const body = {} // some request body data this // access the Blazar API } { const data = {} this$socket // access the SocketCluster instance }
UI
This App Extension offers a basic SignInSignUp component. For a usage example, checkout the demo/src/pages/Index.vue
.
You can use the quasar describe
command after starting the dev server:
$ quasar dev# on another terminal: $ quasar describe SignInSignUp
SignInSignUp
This App Extension automatically registers the component, so you can just use it:
Caveats
This App Extension automatically sends the configured nameSpace
and current i18n locale (as a __locale
field on the request body) to the Blazar zeta.
// to enable the locale detection, you have to assign the vue-i18n instance to Vue.prototype.__i18ni18n = locale fallbackLocale: 'en-us' messages// make sure blazar AE can access the i18nVueprototype__i18n = i18n
Internal i18n
This App Extension comes with i18n on all of its components. It uses the Quasar Language Pack concept.
The relevant i18n files are located in src/components/lang
, and here is an example of it fully implemented.
IMPORTANT: the language of this QAE components changes when the Quasar language itself changes, so if you're using vue-i18n, remember to change the Quasar language too (link above on the concept).