chore: default appKey to 'websocket', add copilot instructions

This commit is contained in:
Fabian @ Blax Software 2026-04-16 08:27:22 +02:00
parent 46ce034aba
commit fed6ee0d11
2 changed files with 20 additions and 1 deletions

19
.github/copilot-instructions.md vendored Normal file
View File

@ -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

View File

@ -71,7 +71,7 @@ export function createFromNuxtConfig(options: NuxtNetworkingOptions = {}): {
const serverUrlInternal: string = pub[serverUrlInternalKey] ?? '' const serverUrlInternal: string = pub[serverUrlInternalKey] ?? ''
const wsUrl: string = pub[wsUrlKey] ?? '' const wsUrl: string = pub[wsUrlKey] ?? ''
const wsProtocol: string = pub[wsProtocolKey] ?? 'wss' const wsProtocol: string = pub[wsProtocolKey] ?? 'wss'
const appKey: string = pub[appKeyConfigKey] ?? '' const appKey: string = pub[appKeyConfigKey] ?? 'websocket'
// @ts-expect-error Nuxt/Vite global // @ts-expect-error Nuxt/Vite global
const isServer: boolean = import.meta.server ?? false const isServer: boolean = import.meta.server ?? false