Core API
createSurf
Create a new Surf instance
createSurf(config)#
Creates a new Surf instance. The config object defines your service name, commands, auth, events, and behavior.
typescript
import { createSurf } from '@surfjs/core'ย const surf = await createSurf({ name: 'My Service', description: 'A Surf-enabled API', version: '1.0.0', commands: { /* ... */ }, events: { /* ... */ }, authVerifier: myVerifier, rateLimit: { windowMs: 60_000, maxRequests: 100 }, strict: true,})ย // Returns a SurfInstance with:surf.manifest() // Get the generated manifestsurf.manifestHandler() // HTTP handler for /.well-known/surf.jsonsurf.httpHandler() // HTTP handler for /surf/executesurf.middleware() // Combined HTTP middleware (manifest + execute + sessions + pipeline)surf.wsHandler(server) // Attach WebSocket transportsurf.emit(event, data) // Emit an event to connected clientssurf.use(middleware) // Add a middleware functionsurf.events // Access the EventBussurf.sessions // Access the SessionStoresurf.commands // Access the CommandRegistry