Skip to main content
ctx.airline (PluginAirlineAccessor) gives read-only access to the currently-bound airline plus a pre-configured HTTP client. See PluginAirlineAccessor and PluginAirline for the full shapes.

getCurrent()

Returns the current airline binding. Re-call it when you need a fresh snapshot — there’s no event subscription.
const airline = await ctx.airline.getCurrent();
ctx.logger.info("MyPlugin", `Bound to ${airline.id} at ${airline.baseUrl}`);
Returns an axios instance pre-configured for the bound airline:
  • baseURL is set to airline.baseUrl (resolved per request).
  • Authorization header carries the current VA bearer.
  • On a 401 response, the shell exchanges the stored refresh token at the VA’s refresh_url. If refresh succeeds, the request is retried exactly once. If the VA didn’t configure a refresh_url, the user has no refresh token, or the VA rejected the refresh, the 401 propagates and the shell’s existing re-auth flow takes over.
Cache the returned instance for the lifetime of the background module — it’s safe to reuse across requests.
import { createPlugin } from "@skyvexsoftware/stratos-sdk/helpers";

export default createPlugin({
  async onStart(ctx) {
    const va = ctx.airline.createClient();

    // Same axios API plugins use in the renderer via useVaApi():
    const { data } = await va.get<{ pilotID: string }>("/pilot/verify");
    ctx.logger.info("MyPlugin", `Verified ${data.pilotID}`);

    await va.post("/pireps", {
      flight_number: "QFA1",
      arrival: "EGLL",
    });
  },

  async onStop() {
    // axios instances don't need explicit teardown
  },
});
When to use it: any time your background module calls the airline’s backend. createClient() is the recommended path (refresh handling for free); reach for getCurrent() when you only need the airline’s identity or base URL. The renderer-side equivalent is useVaApi().