diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..98699fb --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,19 @@ +# blax-npm-networking + +## Overview +Plug-and-play API + WebSocket client for Vue/Nuxt apps. Framework-agnostic core with optional bindings. + +## Build +- `pnpm build` — builds via tsup to `dist/` +- Exports: `.` (core), `./vue`, `./nuxt`, `./axios` + +## WebSocket +- `createWsClient()` takes a URL and connects via native WebSocket +- `createFromNuxtConfig()` reads `runtimeConfig.public` keys: `WEBS_URL`, `WS_PROTOCOL`, `PUSHER_APP_KEY` +- App key default: `websocket` — generic identifier, same in all environments +- URL format: `{protocol}://{host}/app/{appKey}` +- Has built-in connection diagnostics: URL validation, 5s timeout for `connection_established` + +## Conventions +- TypeScript strict mode +- No environment-specific defaults — all config values should work across dev and prod diff --git a/src/nuxt.ts b/src/nuxt.ts index af1be0e..e6aa3cb 100644 --- a/src/nuxt.ts +++ b/src/nuxt.ts @@ -71,7 +71,7 @@ export function createFromNuxtConfig(options: NuxtNetworkingOptions = {}): { const serverUrlInternal: string = pub[serverUrlInternalKey] ?? '' const wsUrl: string = pub[wsUrlKey] ?? '' const wsProtocol: string = pub[wsProtocolKey] ?? 'wss' - const appKey: string = pub[appKeyConfigKey] ?? '' + const appKey: string = pub[appKeyConfigKey] ?? 'websocket' // @ts-expect-error Nuxt/Vite global const isServer: boolean = import.meta.server ?? false